public static double logGamma(double xx){
  double x=xx - 1.0;
  double tmp=x + 5.5;
  tmp-=(x + 0.5) * Math.log(tmp);
  double ser=1.000000000190015;
  double[] coeff=cof;
  for (int j=0; j <= 5; j++) {
    x++;
    ser+=coeff[j] / x;
  }
  return -tmp + Math.log(2.5066282746310005 * ser);
}

public static double logGamma ( double xx ) { double x = xx - 1.0 ; double tmp = x + 5.5 ; tmp -= ( x + 0.5 ) * Math . log ( tmp ) ; double ser = 1.000000000190015 ; double [ ] coeff = cof ; for ( int j = 0 ; j <= 5 ; j ++ ) { x ++ ; ser += coeff [ j ] / x ; } return - tmp + Math . log ( 2.5066282746310005 * ser ) ; }
returns the value ln ( gamma ( xx ) for xx > 0 . full accuracy is obtained for xx > 1 . for 0 < xx < 1 . the reflection formula ( 6 . 1 . 4 ) can be used first . ( adapted from numerical recipes in c )
