alngam.f

Go to the documentation of this file.
00001 *DECK ALNGAM
00002       FUNCTION ALNGAM (X)
00003 C***BEGIN PROLOGUE  ALNGAM
00004 C***PURPOSE  Compute the logarithm of the absolute value of the Gamma
00005 C            function.
00006 C***LIBRARY   SLATEC (FNLIB)
00007 C***CATEGORY  C7A
00008 C***TYPE      SINGLE PRECISION (ALNGAM-S, DLNGAM-D, CLNGAM-C)
00009 C***KEYWORDS  ABSOLUTE VALUE, COMPLETE GAMMA FUNCTION, FNLIB, LOGARITHM,
00010 C             SPECIAL FUNCTIONS
00011 C***AUTHOR  Fullerton, W., (LANL)
00012 C***DESCRIPTION
00013 C
00014 C ALNGAM(X) computes the logarithm of the absolute value of the
00015 C gamma function at X.
00016 C
00017 C***REFERENCES  (NONE)
00018 C***ROUTINES CALLED  GAMMA, R1MACH, R9LGMC, XERMSG
00019 C***REVISION HISTORY  (YYMMDD)
00020 C   770601  DATE WRITTEN
00021 C   890531  Changed all specific intrinsics to generic.  (WRB)
00022 C   890531  REVISION DATE from Version 3.2
00023 C   891214  Prologue converted to Version 4.0 format.  (BAB)
00024 C   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
00025 C   900326  Removed duplicate information from DESCRIPTION section.
00026 C           (WRB)
00027 C   900727  Added EXTERNAL statement.  (WRB)
00028 C***END PROLOGUE  ALNGAM
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 C***FIRST EXECUTABLE STATEMENT  ALNGAM
00037       IF (FIRST) THEN
00038          XMAX = R1MACH(2)/LOG(R1MACH(2))
00039          DXREL = SQRT (R1MACH(4))
00040       ENDIF
00041       FIRST = .FALSE.
00042 C
00043       Y = ABS(X)
00044       IF (Y.GT.10.0) GO TO 20
00045 C
00046 C LOG (ABS (GAMMA(X))) FOR  ABS(X) .LE. 10.0
00047 C
00048       ALNGAM = LOG (ABS (GAMMA(X)))
00049       RETURN
00050 C
00051 C LOG (ABS (GAMMA(X))) FOR ABS(X) .GT. 10.0
00052 C
00053  20   IF (Y .GT. XMAX) CALL XERMSG ('SLATEC', 'ALNGAM',
00054      +   'ABS(X) SO BIG ALNGAM OVERFLOWS', 2, 2)
00055 C
00056       IF (X.GT.0.) ALNGAM = SQ2PIL + (X-0.5)*LOG(X) - X + R9LGMC(Y)
00057       IF (X.GT.0.) RETURN
00058 C
00059       SINPIY = ABS (SIN(PI*Y))
00060       IF (SINPIY .EQ. 0.) CALL XERMSG ('SLATEC', 'ALNGAM',
00061      +   'X IS A NEGATIVE INTEGER', 3, 2)
00062 C
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 C
00067       ALNGAM = SQPI2L + (X-0.5)*LOG(Y) - X - LOG(SINPIY) - R9LGMC(Y)
00068       RETURN
00069 C
00070       END
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines