zlog.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* zlog.f -- translated by f2c (version 20100827).
  2. This file no longer depends on f2c.
  3. */
  4. #include "slatec-internal.hpp"
  5. int zlog_(double *ar, double *ai, double *br,
  6. double *bi, integer *ierr)
  7. {
  8. /* Initialized data */
  9. static double const dpi = 3.141592653589793238462643383;
  10. static double const dhpi = 1.570796326794896619231321696;
  11. /* Local variables */
  12. double zm;
  13. double dtheta;
  14. /* ***BEGIN PROLOGUE ZLOG */
  15. /* ***SUBSIDIARY */
  16. /* ***PURPOSE Subsidiary to ZBESH, ZBESI, ZBESJ, ZBESK, ZBESY, ZAIRY and */
  17. /* ZBIRY */
  18. /* ***LIBRARY SLATEC */
  19. /* ***TYPE ALL (ZLOG-A) */
  20. /* ***AUTHOR Amos, D. E., (SNL) */
  21. /* ***DESCRIPTION */
  22. /* DOUBLE PRECISION COMPLEX LOGARITHM B=CLOG(A) */
  23. /* IERR=0,NORMAL RETURN IERR=1, Z=CMPLX(0.0,0.0) */
  24. /* ***SEE ALSO ZAIRY, ZBESH, ZBESI, ZBESJ, ZBESK, ZBESY, ZBIRY */
  25. /* ***ROUTINES CALLED ZABS */
  26. /* ***REVISION HISTORY (YYMMDD) */
  27. /* 830501 DATE WRITTEN */
  28. /* 910415 Prologue converted to Version 4.0 format. (BAB) */
  29. /* ***END PROLOGUE ZLOG */
  30. /* ***FIRST EXECUTABLE STATEMENT ZLOG */
  31. *ierr = 0;
  32. if (*ar == 0.) {
  33. goto L10;
  34. }
  35. if (*ai == 0.) {
  36. goto L20;
  37. }
  38. dtheta = atan(*ai / *ar);
  39. if (dtheta <= 0.) {
  40. goto L40;
  41. }
  42. if (*ar < 0.) {
  43. dtheta -= dpi;
  44. }
  45. goto L50;
  46. L10:
  47. if (*ai == 0.) {
  48. goto L60;
  49. }
  50. *bi = dhpi;
  51. *br = log((abs(*ai)));
  52. if (*ai < 0.) {
  53. *bi = -(*bi);
  54. }
  55. return 0;
  56. L20:
  57. if (*ar > 0.) {
  58. goto L30;
  59. }
  60. *br = log((abs(*ar)));
  61. *bi = dpi;
  62. return 0;
  63. L30:
  64. *br = log(*ar);
  65. *bi = 0.;
  66. return 0;
  67. L40:
  68. if (*ar < 0.) {
  69. dtheta += dpi;
  70. }
  71. L50:
  72. zm = zabs_(ar, ai);
  73. *br = log(zm);
  74. *bi = dtheta;
  75. return 0;
  76. L60:
  77. *ierr = 1;
  78. return 0;
  79. } /* zlog_ */