2019-03-20 12:25:42 +02:00
|
|
|
SUBROUTINE AZSQRT(AR, AI, BR, BI)
|
|
|
|
C***BEGIN PROLOGUE AZSQRT
|
2019-03-19 16:42:47 +02:00
|
|
|
C***REFER TO ZBESH,ZBESI,ZBESJ,ZBESK,ZBESY,ZAIRY,ZBIRY
|
|
|
|
C
|
|
|
|
C DOUBLE PRECISION COMPLEX SQUARE ROOT, B=CSQRT(A)
|
|
|
|
C
|
2019-03-20 12:25:42 +02:00
|
|
|
C***ROUTINES CALLED AZABS
|
|
|
|
C***END PROLOGUE AZSQRT
|
2019-03-19 16:42:47 +02:00
|
|
|
DOUBLE PRECISION AR, AI, BR, BI, ZM, DTHETA, DPI, DRT
|
2019-03-20 12:25:42 +02:00
|
|
|
DOUBLE PRECISION AZABS
|
2019-03-19 16:42:47 +02:00
|
|
|
DATA DRT , DPI / 7.071067811865475244008443621D-1,
|
|
|
|
1 3.141592653589793238462643383D+0/
|
2019-03-20 12:25:42 +02:00
|
|
|
ZM = AZABS(AR,AI)
|
2019-03-19 16:42:47 +02:00
|
|
|
ZM = DSQRT(ZM)
|
|
|
|
IF (AR.EQ.0.0D+0) GO TO 10
|
|
|
|
IF (AI.EQ.0.0D+0) GO TO 20
|
|
|
|
DTHETA = DATAN(AI/AR)
|
|
|
|
IF (DTHETA.LE.0.0D+0) GO TO 40
|
|
|
|
IF (AR.LT.0.0D+0) DTHETA = DTHETA - DPI
|
|
|
|
GO TO 50
|
|
|
|
10 IF (AI.GT.0.0D+0) GO TO 60
|
|
|
|
IF (AI.LT.0.0D+0) GO TO 70
|
|
|
|
BR = 0.0D+0
|
|
|
|
BI = 0.0D+0
|
|
|
|
RETURN
|
|
|
|
20 IF (AR.GT.0.0D+0) GO TO 30
|
|
|
|
BR = 0.0D+0
|
|
|
|
BI = DSQRT(DABS(AR))
|
|
|
|
RETURN
|
|
|
|
30 BR = DSQRT(AR)
|
|
|
|
BI = 0.0D+0
|
|
|
|
RETURN
|
|
|
|
40 IF (AR.LT.0.0D+0) DTHETA = DTHETA + DPI
|
|
|
|
50 DTHETA = DTHETA*0.5D+0
|
|
|
|
BR = ZM*DCOS(DTHETA)
|
|
|
|
BI = ZM*DSIN(DTHETA)
|
|
|
|
RETURN
|
|
|
|
60 BR = ZM*DRT
|
|
|
|
BI = ZM*DRT
|
|
|
|
RETURN
|
|
|
|
70 BR = ZM*DRT
|
|
|
|
BI = -ZM*DRT
|
|
|
|
RETURN
|
|
|
|
END
|