Gamma { private Gamma() {} 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 testGamma() { for (int i = 0; i < GAMMA_REF.length; i++) { final double[] ref = GAMMA_REF[i]; final double x = ref[0]; final double expected = ref[1]; final double actual = Gamma.gamma(x); final double absX = FastMath.abs(x); final int ulps; if (absX <= 8.0) { ulps = 3; } else if (absX <= 20.0) { ulps = 5; } else if (absX <= 30.0) { ulps = 50; } else if (absX <= 50.0) { ulps = 180; } else { ulps = 500; } final double tol = ulps * FastMath.ulp(expected); Assert.assertEquals(Double.toString(x), expected, actual, tol); } }
@Test public void testGammaNegativeInteger() { for (int i = -100; i <= 0; i++) { Assert.assertTrue(Integer.toString(i), Double.isNaN(Gamma.gamma(i))); } }