GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
alngam.f
Go to the documentation of this file.
1*DECK ALNGAM
2 FUNCTION alngam (X)
3C***BEGIN PROLOGUE ALNGAM
4C***PURPOSE Compute the logarithm of the absolute value of the Gamma
5C function.
6C***LIBRARY SLATEC (FNLIB)
7C***CATEGORY C7A
8C***TYPE SINGLE PRECISION (ALNGAM-S, DLNGAM-D, CLNGAM-C)
9C***KEYWORDS ABSOLUTE VALUE, COMPLETE GAMMA FUNCTION, FNLIB, LOGARITHM,
10C SPECIAL FUNCTIONS
11C***AUTHOR Fullerton, W., (LANL)
12C***DESCRIPTION
13C
14C ALNGAM(X) computes the logarithm of the absolute value of the
15C gamma function at X.
16C
17C***REFERENCES (NONE)
18C***ROUTINES CALLED GAMMA, R1MACH, R9LGMC, XERMSG
19C***REVISION HISTORY (YYMMDD)
20C 770601 DATE WRITTEN
21C 890531 Changed all specific intrinsics to generic. (WRB)
22C 890531 REVISION DATE from Version 3.2
23C 891214 Prologue converted to Version 4.0 format. (BAB)
24C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
25C 900326 Removed duplicate information from DESCRIPTION section.
26C (WRB)
27C 900727 Added EXTERNAL statement. (WRB)
28C***END PROLOGUE ALNGAM
29 LOGICAL first
30 EXTERNAL gamma
31 SAVE sq2pil, sqpi2l, pi, xmax, dxrel, first
32 DATA sq2pil / 0.9189385332 0467274e0/
33 DATA sqpi2l / 0.2257913526 4472743e0/
34 DATA pi / 3.1415926535 8979324e0/
35 DATA first /.true./
36C***FIRST EXECUTABLE STATEMENT ALNGAM
37 IF (first) THEN
38 xmax = r1mach(2)/log(r1mach(2))
39 dxrel = sqrt(r1mach(4))
40 ENDIF
41 first = .false.
42C
43 y = abs(x)
44 IF (y.GT.10.0) GO TO 20
45C
46C LOG (ABS (GAMMA(X))) FOR ABS(X) .LE. 10.0
47C
48 alngam = log(abs(gamma(x)))
49 RETURN
50C
51C LOG (ABS (GAMMA(X))) FOR ABS(X) .GT. 10.0
52C
53 20 IF (y .GT. xmax) CALL xermsg ('SLATEC', 'ALNGAM',
54 + 'ABS(X) SO BIG ALNGAM OVERFLOWS', 2, 2)
55C
56 IF (x.GT.0.) alngam = sq2pil + (x-0.5)*log(x) - x + r9lgmc(y)
57 IF (x.GT.0.) RETURN
58C
59 sinpiy = abs(sin(pi*y))
60 IF (sinpiy .EQ. 0.) CALL xermsg ('SLATEC', 'ALNGAM',
61 + 'X IS A NEGATIVE INTEGER', 3, 2)
62C
63 IF (abs((x-aint(x-0.5))/x) .LT. dxrel) CALL xermsg ('SLATEC',
64 + 'ALNGAM', 'ANSWER LT HALF PRECISION BECAUSE X TOO NEAR ' //
65 + 'NEGATIVE INTEGER', 1, 1)
66C
67 alngam = sqpi2l + (x-0.5)*log(y) - x - log(sinpiy) - r9lgmc(y)
68 RETURN
69C
70 END
function alngam(x)
Definition alngam.f:3
function gamma(x)
Definition gamma.f:3
octave_int< T > xmax(const octave_int< T > &x, const octave_int< T > &y)
real function r1mach(i)
Definition r1mach.f:23
function r9lgmc(x)
Definition r9lgmc.f:3
subroutine xermsg(librar, subrou, messg, nerr, level)
Definition xermsg.f:3