### Question:
LogMath { public static double logSum(double logA, double logB) { if (Double.isInfinite(logA)) { return logB; } if (Double.isInfinite(logB)) { return logA; } if (logA > logB) { double dif = logA - logB; return dif >= 30d ? logA : logA + Math.log(1 + Math.exp(-dif)); } else { double dif = logB - logA; return dif >= 30d ? logB : logB + Math.log(1 + Math.exp(-dif)); } } private  LogMath(); static double logSum(double logA, double logB); static double logSum10(double log10A, double log10B); static double logSum(double... logValues); static double log(double base, double val); static double log2(double input); static double log10ToLog(double log10Value); static double toLogSphinx(double logValue); static void main(String[] args); static final double LOG_ZERO; static final double LOG_ONE; static final double LOG_TEN; static final double LOG_TWO; static final double INVERSE_LOG_TWO; static final float LOG_ZERO_FLOAT; static final float LOG_ONE_FLOAT; static final float LOG_TEN_FLOAT; static final float LOG_TWO_FLOAT; static final LogSumLookup LOG_SUM; static final LogSumLookupFloat LOG_SUM_FLOAT; static final LinearToLogConverter LINEAR_TO_LOG; static final LinearToLogConverterFloat LINEAR_TO_LOG_FLOAT; }### Answer:
@Test public void logSumTest() throws IOException { double[] aLinear = new double[1000]; double[] bLinear = new double[1000]; for (int i = 0; i < bLinear.length; i++) { aLinear[i] = (double) i / 1000d; bLinear[i] = aLinear[i]; } LogMath.LogSumLookup logSumE = LogMath.LOG_SUM; for (double a : aLinear) { for (double b : bLinear) { double logSumExpected = Math.log(a + b); Assert.assertEquals(logSumExpected, logSumE.lookup(Math.log(a), Math.log(b)), 0.001); } } }