cuoik.f

Go to the documentation of this file.
00001       SUBROUTINE CUOIK(Z, FNU, KODE, IKFLG, N, Y, NUF, TOL, ELIM, ALIM)
00002 C***BEGIN PROLOGUE  CUOIK
00003 C***REFER TO  CBESI,CBESK,CBESH
00004 C
00005 C     CUOIK COMPUTES THE LEADING TERMS OF THE UNIFORM ASYMPTOTIC
00006 C     EXPANSIONS FOR THE I AND K FUNCTIONS AND COMPARES THEM
00007 C     (IN LOGARITHMIC FORM) TO ALIM AND ELIM FOR OVER AND UNDERFLOW
00008 C     WHERE ALIM.LT.ELIM. IF THE MAGNITUDE, BASED ON THE LEADING
00009 C     EXPONENTIAL, IS LESS THAN ALIM OR GREATER THAN -ALIM, THEN
00010 C     THE RESULT IS ON SCALE. IF NOT, THEN A REFINED TEST USING OTHER
00011 C     MULTIPLIERS (IN LOGARITHMIC FORM) IS MADE BASED ON ELIM. HERE
00012 C     EXP(-ELIM)=SMALLEST MACHINE NUMBER*1.0E+3 AND EXP(-ALIM)=
00013 C     EXP(-ELIM)/TOL
00014 C
00015 C     IKFLG=1 MEANS THE I SEQUENCE IS TESTED
00016 C          =2 MEANS THE K SEQUENCE IS TESTED
00017 C     NUF = 0 MEANS THE LAST MEMBER OF THE SEQUENCE IS ON SCALE
00018 C         =-1 MEANS AN OVERFLOW WOULD OCCUR
00019 C     IKFLG=1 AND NUF.GT.0 MEANS THE LAST NUF Y VALUES WERE SET TO ZERO
00020 C             THE FIRST N-NUF VALUES MUST BE SET BY ANOTHER ROUTINE
00021 C     IKFLG=2 AND NUF.EQ.N MEANS ALL Y VALUES WERE SET TO ZERO
00022 C     IKFLG=2 AND 0.LT.NUF.LT.N NOT CONSIDERED. Y MUST BE SET BY
00023 C             ANOTHER ROUTINE
00024 C
00025 C***ROUTINES CALLED  CUCHK,CUNHJ,CUNIK,R1MACH
00026 C***END PROLOGUE  CUOIK
00027       COMPLEX ARG, ASUM, BSUM, CWRK, CZ, CZERO, PHI, SUM, Y, Z, ZB,
00028      * ZETA1, ZETA2, ZN, ZR
00029       REAL AARG, AIC, ALIM, APHI, ASCLE, AX, AY, ELIM, FNN, FNU, GNN,
00030      * GNU, RCZ, TOL, X, YY
00031       INTEGER I, IFORM, IKFLG, INIT, KODE, N, NN, NUF, NW
00032       DIMENSION Y(N), CWRK(16)
00033       DATA CZERO / (0.0E0,0.0E0) /
00034       DATA AIC / 1.265512123484645396E+00 /
00035       NUF = 0
00036       NN = N
00037       X = REAL(Z)
00038       ZR = Z
00039       IF (X.LT.0.0E0) ZR = -Z
00040       ZB = ZR
00041       YY = AIMAG(ZR)
00042       AX = ABS(X)*1.7321E0
00043       AY = ABS(YY)
00044       IFORM = 1
00045       IF (AY.GT.AX) IFORM = 2
00046       GNU = AMAX1(FNU,1.0E0)
00047       IF (IKFLG.EQ.1) GO TO 10
00048       FNN = FLOAT(NN)
00049       GNN = FNU + FNN - 1.0E0
00050       GNU = AMAX1(GNN,FNN)
00051    10 CONTINUE
00052 C-----------------------------------------------------------------------
00053 C     ONLY THE MAGNITUDE OF ARG AND PHI ARE NEEDED ALONG WITH THE
00054 C     REAL PARTS OF ZETA1, ZETA2 AND ZB. NO ATTEMPT IS MADE TO GET
00055 C     THE SIGN OF THE IMAGINARY PART CORRECT.
00056 C-----------------------------------------------------------------------
00057       IF (IFORM.EQ.2) GO TO 20
00058       INIT = 0
00059       CALL CUNIK(ZR, GNU, IKFLG, 1, TOL, INIT, PHI, ZETA1, ZETA2, SUM,
00060      * CWRK)
00061       CZ = -ZETA1 + ZETA2
00062       GO TO 40
00063    20 CONTINUE
00064       ZN = -ZR*CMPLX(0.0E0,1.0E0)
00065       IF (YY.GT.0.0E0) GO TO 30
00066       ZN = CONJG(-ZN)
00067    30 CONTINUE
00068       CALL CUNHJ(ZN, GNU, 1, TOL, PHI, ARG, ZETA1, ZETA2, ASUM, BSUM)
00069       CZ = -ZETA1 + ZETA2
00070       AARG = CABS(ARG)
00071    40 CONTINUE
00072       IF (KODE.EQ.2) CZ = CZ - ZB
00073       IF (IKFLG.EQ.2) CZ = -CZ
00074       APHI = CABS(PHI)
00075       RCZ = REAL(CZ)
00076 C-----------------------------------------------------------------------
00077 C     OVERFLOW TEST
00078 C-----------------------------------------------------------------------
00079       IF (RCZ.GT.ELIM) GO TO 170
00080       IF (RCZ.LT.ALIM) GO TO 50
00081       RCZ = RCZ + ALOG(APHI)
00082       IF (IFORM.EQ.2) RCZ = RCZ - 0.25E0*ALOG(AARG) - AIC
00083       IF (RCZ.GT.ELIM) GO TO 170
00084       GO TO 100
00085    50 CONTINUE
00086 C-----------------------------------------------------------------------
00087 C     UNDERFLOW TEST
00088 C-----------------------------------------------------------------------
00089       IF (RCZ.LT.(-ELIM)) GO TO 60
00090       IF (RCZ.GT.(-ALIM)) GO TO 100
00091       RCZ = RCZ + ALOG(APHI)
00092       IF (IFORM.EQ.2) RCZ = RCZ - 0.25E0*ALOG(AARG) - AIC
00093       IF (RCZ.GT.(-ELIM)) GO TO 80
00094    60 CONTINUE
00095       DO 70 I=1,NN
00096         Y(I) = CZERO
00097    70 CONTINUE
00098       NUF = NN
00099       RETURN
00100    80 CONTINUE
00101       ASCLE = 1.0E+3*R1MACH(1)/TOL
00102       CZ = CZ + CLOG(PHI)
00103       IF (IFORM.EQ.1) GO TO 90
00104       CZ = CZ - CMPLX(0.25E0,0.0E0)*CLOG(ARG) - CMPLX(AIC,0.0E0)
00105    90 CONTINUE
00106       AX = EXP(RCZ)/TOL
00107       AY = AIMAG(CZ)
00108       CZ = CMPLX(AX,0.0E0)*CMPLX(COS(AY),SIN(AY))
00109       CALL CUCHK(CZ, NW, ASCLE, TOL)
00110       IF (NW.EQ.1) GO TO 60
00111   100 CONTINUE
00112       IF (IKFLG.EQ.2) RETURN
00113       IF (N.EQ.1) RETURN
00114 C-----------------------------------------------------------------------
00115 C     SET UNDERFLOWS ON I SEQUENCE
00116 C-----------------------------------------------------------------------
00117   110 CONTINUE
00118       GNU = FNU + FLOAT(NN-1)
00119       IF (IFORM.EQ.2) GO TO 120
00120       INIT = 0
00121       CALL CUNIK(ZR, GNU, IKFLG, 1, TOL, INIT, PHI, ZETA1, ZETA2, SUM,
00122      * CWRK)
00123       CZ = -ZETA1 + ZETA2
00124       GO TO 130
00125   120 CONTINUE
00126       CALL CUNHJ(ZN, GNU, 1, TOL, PHI, ARG, ZETA1, ZETA2, ASUM, BSUM)
00127       CZ = -ZETA1 + ZETA2
00128       AARG = CABS(ARG)
00129   130 CONTINUE
00130       IF (KODE.EQ.2) CZ = CZ - ZB
00131       APHI = CABS(PHI)
00132       RCZ = REAL(CZ)
00133       IF (RCZ.LT.(-ELIM)) GO TO 140
00134       IF (RCZ.GT.(-ALIM)) RETURN
00135       RCZ = RCZ + ALOG(APHI)
00136       IF (IFORM.EQ.2) RCZ = RCZ - 0.25E0*ALOG(AARG) - AIC
00137       IF (RCZ.GT.(-ELIM)) GO TO 150
00138   140 CONTINUE
00139       Y(NN) = CZERO
00140       NN = NN - 1
00141       NUF = NUF + 1
00142       IF (NN.EQ.0) RETURN
00143       GO TO 110
00144   150 CONTINUE
00145       ASCLE = 1.0E+3*R1MACH(1)/TOL
00146       CZ = CZ + CLOG(PHI)
00147       IF (IFORM.EQ.1) GO TO 160
00148       CZ = CZ - CMPLX(0.25E0,0.0E0)*CLOG(ARG) - CMPLX(AIC,0.0E0)
00149   160 CONTINUE
00150       AX = EXP(RCZ)/TOL
00151       AY = AIMAG(CZ)
00152       CZ = CMPLX(AX,0.0E0)*CMPLX(COS(AY),SIN(AY))
00153       CALL CUCHK(CZ, NW, ASCLE, TOL)
00154       IF (NW.EQ.1) GO TO 140
00155       RETURN
00156   170 CONTINUE
00157       NUF = -1
00158       RETURN
00159       END
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines