OpenLibm/slatec/zlog.f

55 lines
1.5 KiB
FortranFixed
Raw Normal View History

*DECK ZLOG
SUBROUTINE ZLOG (AR, AI, BR, BI, IERR)
2012-10-29 10:44:32 +01:00
C***BEGIN PROLOGUE ZLOG
C***SUBSIDIARY
C***PURPOSE Subsidiary to ZBESH, ZBESI, ZBESJ, ZBESK, ZBESY, ZAIRY and
C ZBIRY
C***LIBRARY SLATEC
C***TYPE ALL (ZLOG-A)
C***AUTHOR Amos, D. E., (SNL)
C***DESCRIPTION
2012-10-29 10:44:32 +01:00
C
C DOUBLE PRECISION COMPLEX LOGARITHM B=CLOG(A)
C IERR=0,NORMAL RETURN IERR=1, Z=CMPLX(0.0,0.0)
C***SEE ALSO ZAIRY, ZBESH, ZBESI, ZBESJ, ZBESK, ZBESY, ZBIRY
2012-10-29 10:44:32 +01:00
C***ROUTINES CALLED ZABS
C***REVISION HISTORY (YYMMDD)
C 830501 DATE WRITTEN
C 910415 Prologue converted to Version 4.0 format. (BAB)
2012-10-29 10:44:32 +01:00
C***END PROLOGUE ZLOG
DOUBLE PRECISION AR, AI, BR, BI, ZM, DTHETA, DPI, DHPI
DOUBLE PRECISION ZABS
INTEGER IERR
EXTERNAL ZABS
2012-10-29 10:44:32 +01:00
DATA DPI , DHPI / 3.141592653589793238462643383D+0,
1 1.570796326794896619231321696D+0/
C***FIRST EXECUTABLE STATEMENT ZLOG
2012-10-29 10:44:32 +01:00
IERR=0
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.EQ.0.0D+0) GO TO 60
BI = DHPI
BR = LOG(ABS(AI))
2012-10-29 10:44:32 +01:00
IF (AI.LT.0.0D+0) BI = -BI
RETURN
20 IF (AR.GT.0.0D+0) GO TO 30
BR = LOG(ABS(AR))
2012-10-29 10:44:32 +01:00
BI = DPI
RETURN
30 BR = LOG(AR)
2012-10-29 10:44:32 +01:00
BI = 0.0D+0
RETURN
40 IF (AR.LT.0.0D+0) DTHETA = DTHETA + DPI
50 ZM = ZABS(AR,AI)
BR = LOG(ZM)
2012-10-29 10:44:32 +01:00
BI = DTHETA
RETURN
60 CONTINUE
IERR=1
RETURN
END