zacai.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* zacai.f -- translated by f2c (version 20100827).
  2. This file no longer depends on f2c.
  3. */
  4. #include "slatec-internal.hpp"
  5. /* Table of constant values */
  6. static integer const c__1 = 1;
  7. int zacai_(double *zr, double *zi, double const *fnu,
  8. integer const *kode, integer *mr, integer const *n, double *yr, double *
  9. yi, integer *nz, double *rl, double *tol, double *elim,
  10. double *alim)
  11. {
  12. /* Initialized data */
  13. static double const pi = 3.14159265358979324;
  14. /* Local variables */
  15. double az;
  16. integer nn, nw;
  17. double yy, c1i, c2i, c1r, c2r, arg;
  18. integer iuf;
  19. double cyi[2], fmr, sgn;
  20. integer inu;
  21. double cyr[2], zni, znr, dfnu;
  22. double ascle, csgni, csgnr, cspni, cspnr;
  23. /* ***BEGIN PROLOGUE ZACAI */
  24. /* ***SUBSIDIARY */
  25. /* ***PURPOSE Subsidiary to ZAIRY */
  26. /* ***LIBRARY SLATEC */
  27. /* ***TYPE ALL (CACAI-A, ZACAI-A) */
  28. /* ***AUTHOR Amos, D. E., (SNL) */
  29. /* ***DESCRIPTION */
  30. /* ZACAI APPLIES THE ANALYTIC CONTINUATION FORMULA */
  31. /* K(FNU,ZN*EXP(MP))=K(FNU,ZN)*EXP(-MP*FNU) - MP*I(FNU,ZN) */
  32. /* MP=PI*MR*CMPLX(0.0,1.0) */
  33. /* TO CONTINUE THE K FUNCTION FROM THE RIGHT HALF TO THE LEFT */
  34. /* HALF Z PLANE FOR USE WITH ZAIRY WHERE FNU=1/3 OR 2/3 AND N=1. */
  35. /* ZACAI IS THE SAME AS ZACON WITH THE PARTS FOR LARGER ORDERS AND */
  36. /* RECURRENCE REMOVED. A RECURSIVE CALL TO ZACON CAN RESULT IF ZACON */
  37. /* IS CALLED FROM ZAIRY. */
  38. /* ***SEE ALSO ZAIRY */
  39. /* ***ROUTINES CALLED D1MACH, ZABS, ZASYI, ZBKNU, ZMLRI, ZS1S2, ZSERI */
  40. /* ***REVISION HISTORY (YYMMDD) */
  41. /* 830501 DATE WRITTEN */
  42. /* 910415 Prologue converted to Version 4.0 format. (BAB) */
  43. /* ***END PROLOGUE ZACAI */
  44. /* COMPLEX CSGN,CSPN,C1,C2,Y,Z,ZN,CY */
  45. /* Parameter adjustments */
  46. --yi;
  47. --yr;
  48. /* Function Body */
  49. /* ***FIRST EXECUTABLE STATEMENT ZACAI */
  50. *nz = 0;
  51. znr = -(*zr);
  52. zni = -(*zi);
  53. az = zabs_(zr, zi);
  54. nn = *n;
  55. dfnu = *fnu + (*n - 1);
  56. if (az <= 2.) {
  57. goto L10;
  58. }
  59. if (az * az * .25 > dfnu + 1.) {
  60. goto L20;
  61. }
  62. L10:
  63. /* ----------------------------------------------------------------------- */
  64. /* POWER SERIES FOR THE I FUNCTION */
  65. /* ----------------------------------------------------------------------- */
  66. zseri_(&znr, &zni, fnu, kode, &nn, &yr[1], &yi[1], &nw, tol, elim, alim);
  67. goto L40;
  68. L20:
  69. if (az < *rl) {
  70. goto L30;
  71. }
  72. /* ----------------------------------------------------------------------- */
  73. /* ASYMPTOTIC EXPANSION FOR LARGE Z FOR THE I FUNCTION */
  74. /* ----------------------------------------------------------------------- */
  75. zasyi_(&znr, &zni, fnu, kode, &nn, &yr[1], &yi[1], &nw, rl, tol, elim,
  76. alim);
  77. if (nw < 0) {
  78. goto L80;
  79. }
  80. goto L40;
  81. L30:
  82. /* ----------------------------------------------------------------------- */
  83. /* MILLER ALGORITHM NORMALIZED BY THE SERIES FOR THE I FUNCTION */
  84. /* ----------------------------------------------------------------------- */
  85. zmlri_(&znr, &zni, fnu, kode, &nn, &yr[1], &yi[1], &nw, tol);
  86. if (nw < 0) {
  87. goto L80;
  88. }
  89. L40:
  90. /* ----------------------------------------------------------------------- */
  91. /* ANALYTIC CONTINUATION TO THE LEFT HALF PLANE FOR THE K FUNCTION */
  92. /* ----------------------------------------------------------------------- */
  93. zbknu_(&znr, &zni, fnu, kode, &c__1, cyr, cyi, &nw, tol, elim, alim);
  94. if (nw != 0) {
  95. goto L80;
  96. }
  97. fmr = (double) (*mr);
  98. sgn = -f2c::d_sign(&pi, &fmr);
  99. csgnr = 0.;
  100. csgni = sgn;
  101. if (*kode == 1) {
  102. goto L50;
  103. }
  104. yy = -zni;
  105. csgnr = -csgni * sin(yy);
  106. csgni *= cos(yy);
  107. L50:
  108. /* ----------------------------------------------------------------------- */
  109. /* CALCULATE CSPN=EXP(FNU*PI*I) TO MINIMIZE LOSSES OF SIGNIFICANCE */
  110. /* WHEN FNU IS LARGE */
  111. /* ----------------------------------------------------------------------- */
  112. inu = (integer) (*fnu);
  113. arg = (*fnu - inu) * sgn;
  114. cspnr = cos(arg);
  115. cspni = sin(arg);
  116. if (inu % 2 == 0) {
  117. goto L60;
  118. }
  119. cspnr = -cspnr;
  120. cspni = -cspni;
  121. L60:
  122. c1r = cyr[0];
  123. c1i = cyi[0];
  124. c2r = yr[1];
  125. c2i = yi[1];
  126. if (*kode == 1) {
  127. goto L70;
  128. }
  129. iuf = 0;
  130. ascle = d1mach_(1) * 1e3 / *tol;
  131. zs1s2_(&znr, &zni, &c1r, &c1i, &c2r, &c2i, &nw, &ascle, alim, &iuf);
  132. *nz += nw;
  133. L70:
  134. yr[1] = cspnr * c1r - cspni * c1i + csgnr * c2r - csgni * c2i;
  135. yi[1] = cspnr * c1i + cspni * c1r + csgnr * c2i + csgni * c2r;
  136. return 0;
  137. L80:
  138. *nz = -1;
  139. if (nw == -2) {
  140. *nz = -2;
  141. }
  142. return 0;
  143. } /* zacai_ */