NaturalLogGammaFunction extends Function1D<Double, Double> { @Override public Double evaluate(final Double x) { Validate.isTrue(x > 0, "x must be greater than zero"); return Gamma.logGamma(x); }  @Override Double evaluate(final Double x);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNegativeNumber() { LN_GAMMA.evaluate(-0.1); }
@Test public void testRecurrence() { double z = 12; double gamma = getGammaFunction(LN_GAMMA.evaluate(z)); assertEquals(getGammaFunction(LN_GAMMA.evaluate(z + 1)), z * gamma, gamma * EPS); z = 11.34; gamma = getGammaFunction(LN_GAMMA.evaluate(z)); assertEquals(getGammaFunction(LN_GAMMA.evaluate(z + 1)), z * gamma, gamma * EPS); }
@Test public void testIntegerArgument() { final int x = 5; final double factorial = 24; assertEquals(getGammaFunction(LN_GAMMA.evaluate(Double.valueOf(x))), factorial, EPS); }