zlog.f 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. *DECK ZLOG
  2. SUBROUTINE ZLOG (AR, AI, BR, BI, IERR)
  3. C***BEGIN PROLOGUE ZLOG
  4. C***SUBSIDIARY
  5. C***PURPOSE Subsidiary to ZBESH, ZBESI, ZBESJ, ZBESK, ZBESY, ZAIRY and
  6. C ZBIRY
  7. C***LIBRARY SLATEC
  8. C***TYPE ALL (ZLOG-A)
  9. C***AUTHOR Amos, D. E., (SNL)
  10. C***DESCRIPTION
  11. C
  12. C DOUBLE PRECISION COMPLEX LOGARITHM B=CLOG(A)
  13. C IERR=0,NORMAL RETURN IERR=1, Z=CMPLX(0.0,0.0)
  14. C***SEE ALSO ZAIRY, ZBESH, ZBESI, ZBESJ, ZBESK, ZBESY, ZBIRY
  15. C***ROUTINES CALLED ZABS
  16. C***REVISION HISTORY (YYMMDD)
  17. C 830501 DATE WRITTEN
  18. C 910415 Prologue converted to Version 4.0 format. (BAB)
  19. C***END PROLOGUE ZLOG
  20. DOUBLE PRECISION AR, AI, BR, BI, ZM, DTHETA, DPI, DHPI
  21. DOUBLE PRECISION ZABS
  22. INTEGER IERR
  23. EXTERNAL ZABS
  24. DATA DPI , DHPI / 3.141592653589793238462643383D+0,
  25. 1 1.570796326794896619231321696D+0/
  26. C***FIRST EXECUTABLE STATEMENT ZLOG
  27. IERR=0
  28. IF (AR.EQ.0.0D+0) GO TO 10
  29. IF (AI.EQ.0.0D+0) GO TO 20
  30. DTHETA = DATAN(AI/AR)
  31. IF (DTHETA.LE.0.0D+0) GO TO 40
  32. IF (AR.LT.0.0D+0) DTHETA = DTHETA - DPI
  33. GO TO 50
  34. 10 IF (AI.EQ.0.0D+0) GO TO 60
  35. BI = DHPI
  36. BR = LOG(ABS(AI))
  37. IF (AI.LT.0.0D+0) BI = -BI
  38. RETURN
  39. 20 IF (AR.GT.0.0D+0) GO TO 30
  40. BR = LOG(ABS(AR))
  41. BI = DPI
  42. RETURN
  43. 30 BR = LOG(AR)
  44. BI = 0.0D+0
  45. RETURN
  46. 40 IF (AR.LT.0.0D+0) DTHETA = DTHETA + DPI
  47. 50 ZM = ZABS(AR,AI)
  48. BR = LOG(ZM)
  49. BI = DTHETA
  50. RETURN
  51. 60 CONTINUE
  52. IERR=1
  53. RETURN
  54. END