github.com/gopherd/gonum@v0.0.4/mathext/internal/amos/amoslib/zlog.f (about)

     1        SUBROUTINE ZLOG(AR, AI, BR, BI, IERR)
     2  C***BEGIN PROLOGUE  ZLOG
     3  C***REFER TO  ZBESH,ZBESI,ZBESJ,ZBESK,ZBESY,ZAIRY,ZBIRY
     4  C
     5  C     DOUBLE PRECISION COMPLEX LOGARITHM B=CLOG(A)
     6  C     IERR=0,NORMAL RETURN      IERR=1, Z=CMPLX(0.0,0.0)
     7  C***ROUTINES CALLED  ZABS
     8  C***END PROLOGUE  ZLOG
     9        DOUBLE PRECISION AR, AI, BR, BI, ZM, DTHETA, DPI, DHPI
    10        DOUBLE PRECISION ZABS
    11        DATA DPI , DHPI  / 3.141592653589793238462643383D+0,
    12       1                   1.570796326794896619231321696D+0/
    13  C
    14        IERR=0
    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.EQ.0.0D+0) GO TO 60
    22        BI = DHPI
    23        BR = DLOG(DABS(AI))
    24        IF (AI.LT.0.0D+0) BI = -BI
    25        RETURN
    26     20 IF (AR.GT.0.0D+0) GO TO 30
    27        BR = DLOG(DABS(AR))
    28        BI = DPI
    29        RETURN
    30     30 BR = DLOG(AR)
    31        BI = 0.0D+0
    32        RETURN
    33     40 IF (AR.LT.0.0D+0) DTHETA = DTHETA + DPI
    34     50 ZM = ZABS(CMPLX(AR,AI,kind=KIND(1.0D0)))
    35        BR = DLOG(ZM)
    36        BI = DTHETA
    37        RETURN
    38     60 CONTINUE
    39        IERR=1
    40        RETURN
    41        END