C99 standard compliance for static const initialisers.
[qpms.git] / amos / zsqrt.f
blob43ba617f4ea576f2555c0c35646219d3e51a53ae
1 SUBROUTINE AZSQRT(AR, AI, BR, BI)
2 C***BEGIN PROLOGUE AZSQRT
3 C***REFER TO ZBESH,ZBESI,ZBESJ,ZBESK,ZBESY,ZAIRY,ZBIRY
5 C DOUBLE PRECISION COMPLEX SQUARE ROOT, B=CSQRT(A)
7 C***ROUTINES CALLED AZABS
8 C***END PROLOGUE AZSQRT
9 DOUBLE PRECISION AR, AI, BR, BI, ZM, DTHETA, DPI, DRT
10 DOUBLE PRECISION AZABS
11 DATA DRT , DPI / 7.071067811865475244008443621D-1,
12 1 3.141592653589793238462643383D+0/
13 ZM = AZABS(AR,AI)
14 ZM = DSQRT(ZM)
15 IF (AR.EQ.0.0D+0) GO TO 10
16 IF (AI.EQ.0.0D+0) GO TO 20
17 DTHETA = DATAN(AI/AR)
18 IF (DTHETA.LE.0.0D+0) GO TO 40
19 IF (AR.LT.0.0D+0) DTHETA = DTHETA - DPI
20 GO TO 50
21 10 IF (AI.GT.0.0D+0) GO TO 60
22 IF (AI.LT.0.0D+0) GO TO 70
23 BR = 0.0D+0
24 BI = 0.0D+0
25 RETURN
26 20 IF (AR.GT.0.0D+0) GO TO 30
27 BR = 0.0D+0
28 BI = DSQRT(DABS(AR))
29 RETURN
30 30 BR = DSQRT(AR)
31 BI = 0.0D+0
32 RETURN
33 40 IF (AR.LT.0.0D+0) DTHETA = DTHETA + DPI
34 50 DTHETA = DTHETA*0.5D+0
35 BR = ZM*DCOS(DTHETA)
36 BI = ZM*DSIN(DTHETA)
37 RETURN
38 60 BR = ZM*DRT
39 BI = ZM*DRT
40 RETURN
41 70 BR = ZM*DRT
42 BI = -ZM*DRT
43 RETURN
44 END