### Question:
LogMath { public static double log(double base, double val) { return Math.log(val) / Math.log(base); } 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 logSumFloatTest() throws IOException { float[] aLinear = new float[1000]; float[] bLinear = new float[1000]; for (int i = 0; i < bLinear.length; i++) { aLinear[i] = (float) i / 1000f; bLinear[i] = aLinear[i]; } for (float a : aLinear) { for (float b : bLinear) { float logSumExpected = (float) Math.log(a + b); Assert .assertEquals(logSumExpected, LogMath.LOG_SUM.lookup(Math.log(a), Math.log(b)), 0.001); } } }
@Test public void linearToLogTest() { LogMath.LinearToLogConverter converter = new LogMath.LinearToLogConverter(Math.E); Assert.assertEquals(Math.log(2), converter.convert(2), 0.00000001d); converter = new LogMath.LinearToLogConverter(10d); Assert.assertEquals(Math.log10(2), converter.convert(2), 0.00000001d); }