code: private double getResidual(VarTensor t1, VarTensor t2) {
          assert s == t1.getAlgebra() && s == t2.getAlgebra();
          Tensor.checkEqualSize(t1, t2);
          Tensor.checkSameAlgebra(t1, t2);
          double residual = Double.NEGATIVE_INFINITY;
          for (int c=0; c<t1.size(); c++) {
              double abs = Math.abs(s.toLogProb(t1.get(c)) - s.toLogProb(t2.get(c)));
              if (abs > residual) {
                  residual = abs;
              }
          }
          return residual;
      }
docs: Gets the residual for a new message, as the maximum error over all assignments.
  
  Following the definition of Sutton & McCallum (2007), we compute the residual as the infinity
  norm of the difference of the log of the message vectors.
  
  Note: the returned value is NOT in the semiring / abstract algebra. It is the actual value
  described above.