Gamma { public static double logGamma1p(final double x) throws NumberIsTooSmallException, NumberIsTooLargeException { if (x < -0.5) { throw new NumberIsTooSmallException(x, -0.5, true); } if (x > 1.5) { throw new NumberIsTooLargeException(x, 1.5, true); } return -FastMath.log1p(invGamma1pm1(x)); } private  Gamma(); static double logGamma(double x); static double regularizedGammaP(double a, double x); static double regularizedGammaP(double a,
                                           double x,
                                           double epsilon,
                                           int maxIterations); static double regularizedGammaQ(double a, double x); static double regularizedGammaQ(final double a,
                                           double x,
                                           double epsilon,
                                           int maxIterations); static double digamma(double x); static double trigamma(double x); static double lanczos(final double x); static double invGamma1pm1(final double x); static double logGamma1p(final double x); static double gamma(final double x); static final double GAMMA; static final double LANCZOS_G; }
@Test public void testLogGamma1p() { final int ulps = 3; for (int i = 0; i < LOG_GAMMA1P_REF.length; i++) { final double[] ref = LOG_GAMMA1P_REF[i]; final double x = ref[0]; final double expected = ref[1]; final double actual = Gamma.logGamma1p(x); final double tol = ulps * FastMath.ulp(expected); Assert.assertEquals(Double.toString(x), expected, actual, tol); } }
@Test(expected = NumberIsTooSmallException.class) public void testLogGamma1pPrecondition1() { Gamma.logGamma1p(-0.51); }
@Test(expected = NumberIsTooLargeException.class) public void testLogGamma1pPrecondition2() { Gamma.logGamma1p(1.51); }