cleaned up packages a bit more.
[CommonLispStat.git] / lib / gamln.c
blob7e5510d975bab39aafc65a44da6542c0b9b746fd
1 #include "xmath.h"
3 /*
4 log gamma function from Numerical Recipes
5 */
7 static double cof[6] = {
8 76.18009173,
9 -86.50532033,
10 24.01409822,
11 -1.231739516,
12 0.120858003e-2,
13 -0.536382e-5
16 double gamma(xx)
17 double xx;
19 double x, tmp, ser;
20 int j;
22 if (xx < 1.0) return(gamma(1.0 + xx) - log(xx));
23 else {
24 x = xx - 1.0;
25 tmp = x + 5.5;
26 tmp -= (x + 0.5) * log(tmp);
27 ser = 1.0;
28 for (j = 0; j < 6; j++) {
29 x += 1.0;
30 ser += cof[j] / x;
32 return(-tmp + log(2.50662827465 * ser));