~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to routines/dcd/dlngam.f

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
      DOUBLE PRECISION FUNCTION dlngam(a)
 
2
C**********************************************************************
 
3
C
 
4
C     DOUBLE PRECISION FUNCTION DLNGAM(X)
 
5
C                 Double precision LN of the GAMma function
 
6
C
 
7
C
 
8
C                              Function
 
9
C
 
10
C
 
11
C     Returns the natural logarithm of GAMMA(X).
 
12
C
 
13
C
 
14
C                              Arguments
 
15
C
 
16
C
 
17
C     X --> value at which scaled log gamma is to be returned
 
18
C                    X is DOUBLE PRECISION
 
19
C
 
20
C
 
21
C                              Method
 
22
C
 
23
C
 
24
C     Renames GAMLN from:
 
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.
 
28
C
 
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
 
35
C          DAHLGREN, VIRGINIA
 
36
C--------------------------
 
37
C     D = 0.5*(LN(2*PI) - 1)
 
38
C--------------------------
 
39
C     .. Scalar Arguments ..
 
40
      DOUBLE PRECISION a
 
41
C     ..
 
42
C     .. Local Scalars ..
 
43
      DOUBLE PRECISION c0,c1,c2,c3,c4,c5,d,t,w
 
44
      INTEGER i,n
 
45
C     ..
 
46
C     .. External Functions ..
 
47
      DOUBLE PRECISION gamln1
 
48
      EXTERNAL gamln1
 
49
C     ..
 
50
C     .. Intrinsic Functions ..
 
51
      INTRINSIC dlog
 
52
C     ..
 
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/
 
59
C     ..
 
60
C     .. Executable Statements ..
 
61
C-----------------------------------------------------------------------
 
62
      IF (a.GT.0.8D0) GO TO 10
 
63
      dlngam = gamln1(a) - dlog(a)
 
64
      RETURN
 
65
 
 
66
   10 IF (a.GT.2.25D0) GO TO 20
 
67
      t = (a-0.5D0) - 0.5D0
 
68
      dlngam = gamln1(t)
 
69
      RETURN
 
70
C
 
71
   20 IF (a.GE.10.0D0) GO TO 40
 
72
      n = a - 1.25D0
 
73
      t = a
 
74
      w = 1.0D0
 
75
      DO 30 i = 1,n
 
76
          t = t - 1.0D0
 
77
          w = t*w
 
78
   30 CONTINUE
 
79
      dlngam = gamln1(t-1.0D0) + dlog(w)
 
80
      RETURN
 
81
C
 
82
   40 t = (1.0D0/a)**2
 
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)
 
85
      END