00001 SUBROUTINE ZRATI(ZR, ZI, FNU, N, CYR, CYI, TOL)
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 DOUBLE PRECISION AK, AMAGZ, AP1, AP2, ARG, AZ, CDFNUI, CDFNUR,
00016 * CONEI, CONER, CYI, CYR, CZEROI, CZEROR, DFNU, FDNU, FLAM, FNU,
00017 * FNUP, PTI, PTR, P1I, P1R, P2I, P2R, RAK, RAP1, RHO, RT2, RZI,
00018 * RZR, TEST, TEST1, TOL, TTI, TTR, T1I, T1R, ZI, ZR, XZABS
00019 INTEGER I, ID, IDNU, INU, ITIME, K, KK, MAGZ, N
00020 DIMENSION CYR(N), CYI(N)
00021 DATA CZEROR,CZEROI,CONER,CONEI,RT2/
00022 1 0.0D0, 0.0D0, 1.0D0, 0.0D0, 1.41421356237309505D0 /
00023 AZ = XZABS(ZR,ZI)
00024 INU = INT(SNGL(FNU))
00025 IDNU = INU + N - 1
00026 MAGZ = INT(SNGL(AZ))
00027 AMAGZ = DBLE(FLOAT(MAGZ+1))
00028 FDNU = DBLE(FLOAT(IDNU))
00029 FNUP = DMAX1(AMAGZ,FDNU)
00030 ID = IDNU - MAGZ - 1
00031 ITIME = 1
00032 K = 1
00033 PTR = 1.0D0/AZ
00034 RZR = PTR*(ZR+ZR)*PTR
00035 RZI = -PTR*(ZI+ZI)*PTR
00036 T1R = RZR*FNUP
00037 T1I = RZI*FNUP
00038 P2R = -T1R
00039 P2I = -T1I
00040 P1R = CONER
00041 P1I = CONEI
00042 T1R = T1R + RZR
00043 T1I = T1I + RZI
00044 IF (ID.GT.0) ID = 0
00045 AP2 = XZABS(P2R,P2I)
00046 AP1 = XZABS(P1R,P1I)
00047
00048
00049
00050
00051
00052
00053 ARG = (AP2+AP2)/(AP1*TOL)
00054 TEST1 = DSQRT(ARG)
00055 TEST = TEST1
00056 RAP1 = 1.0D0/AP1
00057 P1R = P1R*RAP1
00058 P1I = P1I*RAP1
00059 P2R = P2R*RAP1
00060 P2I = P2I*RAP1
00061 AP2 = AP2*RAP1
00062 10 CONTINUE
00063 K = K + 1
00064 AP1 = AP2
00065 PTR = P2R
00066 PTI = P2I
00067 P2R = P1R - (T1R*PTR-T1I*PTI)
00068 P2I = P1I - (T1R*PTI+T1I*PTR)
00069 P1R = PTR
00070 P1I = PTI
00071 T1R = T1R + RZR
00072 T1I = T1I + RZI
00073 AP2 = XZABS(P2R,P2I)
00074 IF (AP1.LE.TEST) GO TO 10
00075 IF (ITIME.EQ.2) GO TO 20
00076 AK = XZABS(T1R,T1I)*0.5D0
00077 FLAM = AK + DSQRT(AK*AK-1.0D0)
00078 RHO = DMIN1(AP2/AP1,FLAM)
00079 TEST = TEST1*DSQRT(RHO/(RHO*RHO-1.0D0))
00080 ITIME = 2
00081 GO TO 10
00082 20 CONTINUE
00083 KK = K + 1 - ID
00084 AK = DBLE(FLOAT(KK))
00085 T1R = AK
00086 T1I = CZEROI
00087 DFNU = FNU + DBLE(FLOAT(N-1))
00088 P1R = 1.0D0/AP2
00089 P1I = CZEROI
00090 P2R = CZEROR
00091 P2I = CZEROI
00092 DO 30 I=1,KK
00093 PTR = P1R
00094 PTI = P1I
00095 RAP1 = DFNU + T1R
00096 TTR = RZR*RAP1
00097 TTI = RZI*RAP1
00098 P1R = (PTR*TTR-PTI*TTI) + P2R
00099 P1I = (PTR*TTI+PTI*TTR) + P2I
00100 P2R = PTR
00101 P2I = PTI
00102 T1R = T1R - CONER
00103 30 CONTINUE
00104 IF (P1R.NE.CZEROR .OR. P1I.NE.CZEROI) GO TO 40
00105 P1R = TOL
00106 P1I = TOL
00107 40 CONTINUE
00108 CALL ZDIV(P2R, P2I, P1R, P1I, CYR(N), CYI(N))
00109 IF (N.EQ.1) RETURN
00110 K = N - 1
00111 AK = DBLE(FLOAT(K))
00112 T1R = AK
00113 T1I = CZEROI
00114 CDFNUR = FNU*RZR
00115 CDFNUI = FNU*RZI
00116 DO 60 I=2,N
00117 PTR = CDFNUR + (T1R*RZR-T1I*RZI) + CYR(K+1)
00118 PTI = CDFNUI + (T1R*RZI+T1I*RZR) + CYI(K+1)
00119 AK = XZABS(PTR,PTI)
00120 IF (AK.NE.CZEROR) GO TO 50
00121 PTR = TOL
00122 PTI = TOL
00123 AK = TOL*RT2
00124 50 CONTINUE
00125 RAK = CONER/AK
00126 CYR(K) = RAK*PTR*RAK
00127 CYI(K) = -RAK*PTI*RAK
00128 T1R = T1R - CONER
00129 K = K - 1
00130 60 CONTINUE
00131 RETURN
00132 END