1
DOUBLE PRECISION FUNCTION dlngam(a)
2
C**********************************************************************
4
C DOUBLE PRECISION FUNCTION DLNGAM(X)
5
C Double precision LN of the GAMma function
11
C Returns the natural logarithm of GAMMA(X).
17
C X --> value at which scaled log gamma is to be returned
18
C X is DOUBLE PRECISION
25
C DiDinato, A. R. and Morris, A. H. Algorithm 708: Significant
26
C Digit Computation of the Incomplete Beta Function Ratios. ACM
27
C Trans. Math. Softw. 18 (1993), 360-373.
29
C**********************************************************************
30
C-----------------------------------------------------------------------
31
C EVALUATION OF LN(GAMMA(A)) FOR POSITIVE A
32
C-----------------------------------------------------------------------
33
C WRITTEN BY ALFRED H. MORRIS
34
C NAVAL SURFACE WARFARE CENTER
36
C--------------------------
37
C D = 0.5*(LN(2*PI) - 1)
38
C--------------------------
39
C .. Scalar Arguments ..
43
DOUBLE PRECISION c0,c1,c2,c3,c4,c5,d,t,w
46
C .. External Functions ..
47
DOUBLE PRECISION gamln1
50
C .. Intrinsic Functions ..
53
C .. Data statements ..
54
C--------------------------
55
DATA d/.418938533204673D0/
56
DATA c0/.833333333333333D-01/,c1/-.277777777760991D-02/,
57
+ c2/.793650666825390D-03/,c3/-.595202931351870D-03/,
58
+ c4/.837308034031215D-03/,c5/-.165322962780713D-02/
60
C .. Executable Statements ..
61
C-----------------------------------------------------------------------
62
IF (a.GT.0.8D0) GO TO 10
63
dlngam = gamln1(a) - dlog(a)
66
10 IF (a.GT.2.25D0) GO TO 20
71
20 IF (a.GE.10.0D0) GO TO 40
79
dlngam = gamln1(t-1.0D0) + dlog(w)
83
w = (((((c5*t+c4)*t+c3)*t+c2)*t+c1)*t+c0)/a
84
dlngam = (d+w) + (a-0.5D0)* (dlog(a)-1.0D0)