Go to the documentation of this file.00001
00002 DOUBLE PRECISION FUNCTION DLNGAM (X)
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 DOUBLE PRECISION X, DXREL, PI, SINPIY, SQPI2L, SQ2PIL, XMAX,
00029 1 Y, DGAMMA, D9LGMC, D1MACH, TEMP
00030 LOGICAL FIRST
00031 EXTERNAL DGAMMA
00032 SAVE SQ2PIL, SQPI2L, PI, XMAX, DXREL, FIRST
00033 DATA SQ2PIL / 0.9189385332 0467274178 0329736405 62 D0 /
00034 DATA SQPI2L / +.2257913526 4472743236 3097614947 441 D+0 /
00035 DATA PI / 3.1415926535 8979323846 2643383279 50 D0 /
00036 DATA FIRST /.TRUE./
00037
00038 IF (FIRST) THEN
00039 TEMP = 1.D0/LOG(D1MACH(2))
00040 XMAX = TEMP*D1MACH(2)
00041 DXREL = SQRT(D1MACH(4))
00042 ENDIF
00043 FIRST = .FALSE.
00044
00045 Y = ABS (X)
00046 IF (Y.GT.10.D0) GO TO 20
00047
00048
00049
00050 DLNGAM = LOG (ABS (DGAMMA(X)) )
00051 RETURN
00052
00053
00054
00055 20 IF (Y .GT. XMAX) CALL XERMSG ('SLATEC', 'DLNGAM',
00056 + 'ABS(X) SO BIG DLNGAM OVERFLOWS', 2, 2)
00057
00058 IF (X.GT.0.D0) DLNGAM = SQ2PIL + (X-0.5D0)*LOG(X) - X + D9LGMC(Y)
00059 IF (X.GT.0.D0) RETURN
00060
00061 SINPIY = ABS (SIN(PI*Y))
00062 IF (SINPIY .EQ. 0.D0) CALL XERMSG ('SLATEC', 'DLNGAM',
00063 + 'X IS A NEGATIVE INTEGER', 3, 2)
00064
00065 IF (ABS((X-AINT(X-0.5D0))/X) .LT. DXREL) CALL XERMSG ('SLATEC',
00066 + 'DLNGAM',
00067 + 'ANSWER LT HALF PRECISION BECAUSE X TOO NEAR NEGATIVE INTEGER',
00068 + 1, 1)
00069
00070 DLNGAM = SQPI2L + (X-0.5D0)*LOG(Y) - X - LOG(SINPIY) - D9LGMC(Y)
00071 RETURN
00072
00073 END