code: public static double convertAlgebra(double value, Algebra src, Algebra dst) {
          if (dst.equals(src)) {
              return value;
          } else if (src.equals(RealAlgebra.getInstance())) {
              return dst.fromReal(value);
          } else if (src.equals(LogSemiring.getInstance())) {
              return dst.fromLogProb(value);
          } else if (dst.equals(RealAlgebra.getInstance())) {
              return src.toReal(value);
          } else if (dst.equals(LogSemiring.getInstance())) {
              return src.toLogProb(value);
          } else {
              // We pivot through the real numbers, but this could cause a loss of
              // floating point precision.
              log.warn("FOR TESTING ONLY: unsafe conversion from " + src + " to " + dst);
              return dst.fromReal(src.toReal(value));
          }
      }
docs: TODO: unit test.