OpenLibm/slatec/dbesk0.f
Viral B. Shah c977aa998f Add Makefile.extras to build libopenlibm-extras.
Replace amos with slatec
2012-12-31 16:37:05 -05:00

83 lines
3.5 KiB
Fortran

*DECK DBESK0
DOUBLE PRECISION FUNCTION DBESK0 (X)
C***BEGIN PROLOGUE DBESK0
C***PURPOSE Compute the modified (hyperbolic) Bessel function of the
C third kind of order zero.
C***LIBRARY SLATEC (FNLIB)
C***CATEGORY C10B1
C***TYPE DOUBLE PRECISION (BESK0-S, DBESK0-D)
C***KEYWORDS FNLIB, HYPERBOLIC BESSEL FUNCTION,
C MODIFIED BESSEL FUNCTION, ORDER ZERO, SPECIAL FUNCTIONS,
C THIRD KIND
C***AUTHOR Fullerton, W., (LANL)
C***DESCRIPTION
C
C DBESK0(X) calculates the double precision modified (hyperbolic)
C Bessel function of the third kind of order zero for double
C precision argument X. The argument must be greater than zero
C but not so large that the result underflows.
C
C Series for BK0 on the interval 0. to 4.00000E+00
C with weighted error 3.08E-33
C log weighted error 32.51
C significant figures required 32.05
C decimal places required 33.11
C
C***REFERENCES (NONE)
C***ROUTINES CALLED D1MACH, DBESI0, DBSK0E, DCSEVL, INITDS, XERMSG
C***REVISION HISTORY (YYMMDD)
C 770701 DATE WRITTEN
C 890531 Changed all specific intrinsics to generic. (WRB)
C 890531 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
C***END PROLOGUE DBESK0
DOUBLE PRECISION X, BK0CS(16), XMAX, XMAXT, XSML, Y,
1 D1MACH, DCSEVL, DBESI0, DBSK0E
LOGICAL FIRST
SAVE BK0CS, NTK0, XSML, XMAX, FIRST
DATA BK0CS( 1) / -.3532739323 3902768720 1140060063 153 D-1 /
DATA BK0CS( 2) / +.3442898999 2462848688 6344927529 213 D+0 /
DATA BK0CS( 3) / +.3597993651 5361501626 5721303687 231 D-1 /
DATA BK0CS( 4) / +.1264615411 4469259233 8479508673 447 D-2 /
DATA BK0CS( 5) / +.2286212103 1194517860 8269830297 585 D-4 /
DATA BK0CS( 6) / +.2534791079 0261494573 0790013428 354 D-6 /
DATA BK0CS( 7) / +.1904516377 2202088589 7214059381 366 D-8 /
DATA BK0CS( 8) / +.1034969525 7633624585 1008317853 089 D-10 /
DATA BK0CS( 9) / +.4259816142 7910825765 2445327170 133 D-13 /
DATA BK0CS( 10) / +.1374465435 8807508969 4238325440 000 D-15 /
DATA BK0CS( 11) / +.3570896528 5083735909 9688597333 333 D-18 /
DATA BK0CS( 12) / +.7631643660 1164373766 7498666666 666 D-21 /
DATA BK0CS( 13) / +.1365424988 4407818590 8053333333 333 D-23 /
DATA BK0CS( 14) / +.2075275266 9066680831 9999999999 999 D-26 /
DATA BK0CS( 15) / +.2712814218 0729856000 0000000000 000 D-29 /
DATA BK0CS( 16) / +.3082593887 9146666666 6666666666 666 D-32 /
DATA FIRST /.TRUE./
C***FIRST EXECUTABLE STATEMENT DBESK0
IF (FIRST) THEN
NTK0 = INITDS (BK0CS, 16, 0.1*REAL(D1MACH(3)))
XSML = SQRT(4.0D0*D1MACH(3))
XMAXT = -LOG(D1MACH(1))
XMAX = XMAXT - 0.5D0*XMAXT*LOG(XMAXT)/(XMAXT+0.5D0)
ENDIF
FIRST = .FALSE.
C
IF (X .LE. 0.D0) CALL XERMSG ('SLATEC', 'DBESK0',
+ 'X IS ZERO OR NEGATIVE', 2, 2)
IF (X.GT.2.0D0) GO TO 20
C
Y = 0.D0
IF (X.GT.XSML) Y = X*X
DBESK0 = -LOG(0.5D0*X)*DBESI0(X) - 0.25D0 + DCSEVL (.5D0*Y-1.D0,
1 BK0CS, NTK0)
RETURN
C
20 DBESK0 = 0.D0
IF (X .GT. XMAX) CALL XERMSG ('SLATEC', 'DBESK0',
+ 'X SO BIG K0 UNDERFLOWS', 1, 1)
IF (X.GT.XMAX) RETURN
C
DBESK0 = EXP(-X) * DBSK0E(X)
C
RETURN
END