casyi.f

Go to the documentation of this file.
00001       SUBROUTINE CASYI(Z, FNU, KODE, N, Y, NZ, RL, TOL, ELIM, ALIM)
00002 C***BEGIN PROLOGUE  CASYI
00003 C***REFER TO  CBESI,CBESK
00004 C
00005 C     CASYI COMPUTES THE I BESSEL FUNCTION FOR REAL(Z).GE.0.0 BY
00006 C     MEANS OF THE ASYMPTOTIC EXPANSION FOR LARGE CABS(Z) IN THE
00007 C     REGION CABS(Z).GT.MAX(RL,FNU*FNU/2). NZ=0 IS A NORMAL RETURN.
00008 C     NZ.LT.0 INDICATES AN OVERFLOW ON KODE=1.
00009 C
00010 C***ROUTINES CALLED  R1MACH
00011 C***END PROLOGUE  CASYI
00012       COMPLEX AK1, CK, CONE, CS1, CS2, CZ, CZERO, DK, EZ, P1, RZ, S2,
00013      * Y, Z
00014       REAL AA, ACZ, AEZ, AK, ALIM, ARG, ARM, ATOL, AZ, BB, BK, DFNU,
00015      * DNU2, ELIM, FDN, FNU, PI, RL, RTPI, RTR1, S, SGN, SQK, TOL, X,
00016      * YY, R1MACH
00017       INTEGER I, IB, IL, INU, J, JL, K, KODE, KODED, M, N, NN, NZ
00018       DIMENSION Y(N)
00019       DATA PI, RTPI  /3.14159265358979324E0 , 0.159154943091895336E0 /
00020       DATA CZERO, CONE / (0.0E0,0.0E0), (1.0E0,0.0E0) /
00021 C
00022       NZ = 0
00023       AZ = CABS(Z)
00024       X = REAL(Z)
00025       ARM = 1.0E+3*R1MACH(1)
00026       RTR1 = SQRT(ARM)
00027       IL = MIN0(2,N)
00028       DFNU = FNU + FLOAT(N-IL)
00029 C-----------------------------------------------------------------------
00030 C     OVERFLOW TEST
00031 C-----------------------------------------------------------------------
00032       AK1 = CMPLX(RTPI,0.0E0)/Z
00033       AK1 = CSQRT(AK1)
00034       CZ = Z
00035       IF (KODE.EQ.2) CZ = Z - CMPLX(X,0.0E0)
00036       ACZ = REAL(CZ)
00037       IF (ABS(ACZ).GT.ELIM) GO TO 80
00038       DNU2 = DFNU + DFNU
00039       KODED = 1
00040       IF ((ABS(ACZ).GT.ALIM) .AND. (N.GT.2)) GO TO 10
00041       KODED = 0
00042       AK1 = AK1*CEXP(CZ)
00043    10 CONTINUE
00044       FDN = 0.0E0
00045       IF (DNU2.GT.RTR1) FDN = DNU2*DNU2
00046       EZ = Z*CMPLX(8.0E0,0.0E0)
00047 C-----------------------------------------------------------------------
00048 C     WHEN Z IS IMAGINARY, THE ERROR TEST MUST BE MADE RELATIVE TO THE
00049 C     FIRST RECIPROCAL POWER SINCE THIS IS THE LEADING TERM OF THE
00050 C     EXPANSION FOR THE IMAGINARY PART.
00051 C-----------------------------------------------------------------------
00052       AEZ = 8.0E0*AZ
00053       S = TOL/AEZ
00054       JL = INT(RL+RL) + 2
00055       YY = AIMAG(Z)
00056       P1 = CZERO
00057       IF (YY.EQ.0.0E0) GO TO 20
00058 C-----------------------------------------------------------------------
00059 C     CALCULATE EXP(PI*(0.5+FNU+N-IL)*I) TO MINIMIZE LOSSES OF
00060 C     SIGNIFICANCE WHEN FNU OR N IS LARGE
00061 C-----------------------------------------------------------------------
00062       INU = INT(FNU)
00063       ARG = (FNU-FLOAT(INU))*PI
00064       INU = INU + N - IL
00065       AK = -SIN(ARG)
00066       BK = COS(ARG)
00067       IF (YY.LT.0.0E0) BK = -BK
00068       P1 = CMPLX(AK,BK)
00069       IF (MOD(INU,2).EQ.1) P1 = -P1
00070    20 CONTINUE
00071       DO 50 K=1,IL
00072         SQK = FDN - 1.0E0
00073         ATOL = S*ABS(SQK)
00074         SGN = 1.0E0
00075         CS1 = CONE
00076         CS2 = CONE
00077         CK = CONE
00078         AK = 0.0E0
00079         AA = 1.0E0
00080         BB = AEZ
00081         DK = EZ
00082         DO 30 J=1,JL
00083           CK = CK*CMPLX(SQK,0.0E0)/DK
00084           CS2 = CS2 + CK
00085           SGN = -SGN
00086           CS1 = CS1 + CK*CMPLX(SGN,0.0E0)
00087           DK = DK + EZ
00088           AA = AA*ABS(SQK)/BB
00089           BB = BB + AEZ
00090           AK = AK + 8.0E0
00091           SQK = SQK - AK
00092           IF (AA.LE.ATOL) GO TO 40
00093    30   CONTINUE
00094         GO TO 90
00095    40   CONTINUE
00096         S2 = CS1
00097         IF (X+X.LT.ELIM) S2 = S2 + P1*CS2*CEXP(-Z-Z)
00098         FDN = FDN + 8.0E0*DFNU + 4.0E0
00099         P1 = -P1
00100         M = N - IL + K
00101         Y(M) = S2*AK1
00102    50 CONTINUE
00103       IF (N.LE.2) RETURN
00104       NN = N
00105       K = NN - 2
00106       AK = FLOAT(K)
00107       RZ = (CONE+CONE)/Z
00108       IB = 3
00109       DO 60 I=IB,NN
00110         Y(K) = CMPLX(AK+FNU,0.0E0)*RZ*Y(K+1) + Y(K+2)
00111         AK = AK - 1.0E0
00112         K = K - 1
00113    60 CONTINUE
00114       IF (KODED.EQ.0) RETURN
00115       CK = CEXP(CZ)
00116       DO 70 I=1,NN
00117         Y(I) = Y(I)*CK
00118    70 CONTINUE
00119       RETURN
00120    80 CONTINUE
00121       NZ = -1
00122       RETURN
00123    90 CONTINUE
00124       NZ=-2
00125       RETURN
00126       END
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines