Go to the documentation of this file.00001
00002 FUNCTION ALNGAM (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
00029 LOGICAL FIRST
00030 EXTERNAL GAMMA
00031 SAVE SQ2PIL, SQPI2L, PI, XMAX, DXREL, FIRST
00032 DATA SQ2PIL / 0.9189385332 0467274E0/
00033 DATA SQPI2L / 0.2257913526 4472743E0/
00034 DATA PI / 3.1415926535 8979324E0/
00035 DATA FIRST /.TRUE./
00036
00037 IF (FIRST) THEN
00038 XMAX = R1MACH(2)/LOG(R1MACH(2))
00039 DXREL = SQRT (R1MACH(4))
00040 ENDIF
00041 FIRST = .FALSE.
00042
00043 Y = ABS(X)
00044 IF (Y.GT.10.0) GO TO 20
00045
00046
00047
00048 ALNGAM = LOG (ABS (GAMMA(X)))
00049 RETURN
00050
00051
00052
00053 20 IF (Y .GT. XMAX) CALL XERMSG ('SLATEC', 'ALNGAM',
00054 + 'ABS(X) SO BIG ALNGAM OVERFLOWS', 2, 2)
00055
00056 IF (X.GT.0.) ALNGAM = SQ2PIL + (X-0.5)*LOG(X) - X + R9LGMC(Y)
00057 IF (X.GT.0.) RETURN
00058
00059 SINPIY = ABS (SIN(PI*Y))
00060 IF (SINPIY .EQ. 0.) CALL XERMSG ('SLATEC', 'ALNGAM',
00061 + 'X IS A NEGATIVE INTEGER', 3, 2)
00062
00063 IF (ABS((X-AINT(X-0.5))/X) .LT. DXREL) CALL XERMSG ('SLATEC',
00064 + 'ALNGAM', 'ANSWER LT HALF PRECISION BECAUSE X TOO NEAR ' //
00065 + 'NEGATIVE INTEGER', 1, 1)
00066
00067 ALNGAM = SQPI2L + (X-0.5)*LOG(Y) - X - LOG(SINPIY) - R9LGMC(Y)
00068 RETURN
00069
00070 END