zbinu.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /* zbinu.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. static integer const c__2 = 2;
  8. int zbinu_(double *zr, double *zi, double const *fnu,
  9. integer const *kode, integer const *n, double *cyr, double *cyi, integer *
  10. nz, double *rl, double *fnul, double *tol, double *
  11. elim, double *alim)
  12. {
  13. /* Initialized data */
  14. static double const zeror = 0.;
  15. static double const zeroi = 0.;
  16. /* System generated locals */
  17. integer i__1;
  18. /* Local variables */
  19. integer i__;
  20. double az;
  21. integer nn, nw;
  22. double cwi[2], cwr[2];
  23. integer nui, inw;
  24. double dfnu;
  25. integer nlast;
  26. /* ***BEGIN PROLOGUE ZBINU */
  27. /* ***SUBSIDIARY */
  28. /* ***PURPOSE Subsidiary to ZAIRY, ZBESH, ZBESI, ZBESJ, ZBESK and ZBIRY */
  29. /* ***LIBRARY SLATEC */
  30. /* ***TYPE ALL (CBINU-A, ZBINU-A) */
  31. /* ***AUTHOR Amos, D. E., (SNL) */
  32. /* ***DESCRIPTION */
  33. /* ZBINU COMPUTES THE I FUNCTION IN THE RIGHT HALF Z PLANE */
  34. /* ***SEE ALSO ZAIRY, ZBESH, ZBESI, ZBESJ, ZBESK, ZBIRY */
  35. /* ***ROUTINES CALLED ZABS, ZASYI, ZBUNI, ZMLRI, ZSERI, ZUOIK, ZWRSK */
  36. /* ***REVISION HISTORY (YYMMDD) */
  37. /* 830501 DATE WRITTEN */
  38. /* 910415 Prologue converted to Version 4.0 format. (BAB) */
  39. /* ***END PROLOGUE ZBINU */
  40. /* Parameter adjustments */
  41. --cyi;
  42. --cyr;
  43. /* Function Body */
  44. /* ***FIRST EXECUTABLE STATEMENT ZBINU */
  45. *nz = 0;
  46. az = zabs_(zr, zi);
  47. nn = *n;
  48. dfnu = *fnu + (*n - 1);
  49. if (az <= 2.) {
  50. goto L10;
  51. }
  52. if (az * az * .25 > dfnu + 1.) {
  53. goto L20;
  54. }
  55. L10:
  56. /* ----------------------------------------------------------------------- */
  57. /* POWER SERIES */
  58. /* ----------------------------------------------------------------------- */
  59. zseri_(zr, zi, fnu, kode, &nn, &cyr[1], &cyi[1], &nw, tol, elim, alim);
  60. inw = abs(nw);
  61. *nz += inw;
  62. nn -= inw;
  63. if (nn == 0) {
  64. return 0;
  65. }
  66. if (nw >= 0) {
  67. goto L120;
  68. }
  69. dfnu = *fnu + (nn - 1);
  70. L20:
  71. if (az < *rl) {
  72. goto L40;
  73. }
  74. if (dfnu <= 1.) {
  75. goto L30;
  76. }
  77. if (az + az < dfnu * dfnu) {
  78. goto L50;
  79. }
  80. /* ----------------------------------------------------------------------- */
  81. /* ASYMPTOTIC EXPANSION FOR LARGE Z */
  82. /* ----------------------------------------------------------------------- */
  83. L30:
  84. zasyi_(zr, zi, fnu, kode, &nn, &cyr[1], &cyi[1], &nw, rl, tol, elim, alim)
  85. ;
  86. if (nw < 0) {
  87. goto L130;
  88. }
  89. goto L120;
  90. L40:
  91. if (dfnu <= 1.) {
  92. goto L70;
  93. }
  94. L50:
  95. /* ----------------------------------------------------------------------- */
  96. /* OVERFLOW AND UNDERFLOW TEST ON I SEQUENCE FOR MILLER ALGORITHM */
  97. /* ----------------------------------------------------------------------- */
  98. zuoik_(zr, zi, fnu, kode, &c__1, &nn, &cyr[1], &cyi[1], &nw, tol, elim,
  99. alim);
  100. if (nw < 0) {
  101. goto L130;
  102. }
  103. *nz += nw;
  104. nn -= nw;
  105. if (nn == 0) {
  106. return 0;
  107. }
  108. dfnu = *fnu + (nn - 1);
  109. if (dfnu > *fnul) {
  110. goto L110;
  111. }
  112. if (az > *fnul) {
  113. goto L110;
  114. }
  115. L60:
  116. if (az > *rl) {
  117. goto L80;
  118. }
  119. L70:
  120. /* ----------------------------------------------------------------------- */
  121. /* MILLER ALGORITHM NORMALIZED BY THE SERIES */
  122. /* ----------------------------------------------------------------------- */
  123. zmlri_(zr, zi, fnu, kode, &nn, &cyr[1], &cyi[1], &nw, tol);
  124. if (nw < 0) {
  125. goto L130;
  126. }
  127. goto L120;
  128. L80:
  129. /* ----------------------------------------------------------------------- */
  130. /* MILLER ALGORITHM NORMALIZED BY THE WRONSKIAN */
  131. /* ----------------------------------------------------------------------- */
  132. /* ----------------------------------------------------------------------- */
  133. /* OVERFLOW TEST ON K FUNCTIONS USED IN WRONSKIAN */
  134. /* ----------------------------------------------------------------------- */
  135. zuoik_(zr, zi, fnu, kode, &c__2, &c__2, cwr, cwi, &nw, tol, elim, alim);
  136. if (nw >= 0) {
  137. goto L100;
  138. }
  139. *nz = nn;
  140. i__1 = nn;
  141. for (i__ = 1; i__ <= i__1; ++i__) {
  142. cyr[i__] = zeror;
  143. cyi[i__] = zeroi;
  144. /* L90: */
  145. }
  146. return 0;
  147. L100:
  148. if (nw > 0) {
  149. goto L130;
  150. }
  151. zwrsk_(zr, zi, fnu, kode, &nn, &cyr[1], &cyi[1], &nw, cwr, cwi, tol, elim,
  152. alim);
  153. if (nw < 0) {
  154. goto L130;
  155. }
  156. goto L120;
  157. L110:
  158. /* ----------------------------------------------------------------------- */
  159. /* INCREMENT FNU+NN-1 UP TO FNUL, COMPUTE AND RECUR BACKWARD */
  160. /* ----------------------------------------------------------------------- */
  161. nui = (integer) (*fnul - dfnu + 1);
  162. nui = max(nui,0);
  163. zbuni_(zr, zi, fnu, kode, &nn, &cyr[1], &cyi[1], &nw, &nui, &nlast, fnul,
  164. tol, elim, alim);
  165. if (nw < 0) {
  166. goto L130;
  167. }
  168. *nz += nw;
  169. if (nlast == 0) {
  170. goto L120;
  171. }
  172. nn = nlast;
  173. goto L60;
  174. L120:
  175. return 0;
  176. L130:
  177. *nz = -1;
  178. if (nw == -2) {
  179. *nz = -2;
  180. }
  181. return 0;
  182. } /* zbinu_ */