zbuni.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /* zbuni.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__2 = 2;
  7. static integer const c__1 = 1;
  8. int zbuni_(double *zr, double *zi, double const *fnu,
  9. integer const *kode, integer const *n, double *yr, double *yi, integer *
  10. nz, integer *nui, integer *nlast, double *fnul, double *tol,
  11. double *elim, double *alim)
  12. {
  13. /* System generated locals */
  14. integer i__1;
  15. /* Local variables */
  16. integer i__, k;
  17. double ax, ay;
  18. integer nl, nw;
  19. double c1i, c1m, c1r, s1i, s2i, s1r, s2r, cyi[2], gnu, raz, cyr[2],
  20. sti, bry[3], rzi, str, rzr, dfnu;
  21. double fnui;
  22. integer iflag;
  23. double ascle, csclr, cscrr;
  24. integer iform;
  25. /* ***BEGIN PROLOGUE ZBUNI */
  26. /* ***SUBSIDIARY */
  27. /* ***PURPOSE Subsidiary to ZBESI and ZBESK */
  28. /* ***LIBRARY SLATEC */
  29. /* ***TYPE ALL (CBUNI-A, ZBUNI-A) */
  30. /* ***AUTHOR Amos, D. E., (SNL) */
  31. /* ***DESCRIPTION */
  32. /* ZBUNI COMPUTES THE I BESSEL FUNCTION FOR LARGE ABS(Z).GT. */
  33. /* FNUL AND FNU+N-1.LT.FNUL. THE ORDER IS INCREASED FROM */
  34. /* FNU+N-1 GREATER THAN FNUL BY ADDING NUI AND COMPUTING */
  35. /* ACCORDING TO THE UNIFORM ASYMPTOTIC EXPANSION FOR I(FNU,Z) */
  36. /* ON IFORM=1 AND THE EXPANSION FOR J(FNU,Z) ON IFORM=2 */
  37. /* ***SEE ALSO ZBESI, ZBESK */
  38. /* ***ROUTINES CALLED D1MACH, ZABS, ZUNI1, ZUNI2 */
  39. /* ***REVISION HISTORY (YYMMDD) */
  40. /* 830501 DATE WRITTEN */
  41. /* 910415 Prologue converted to Version 4.0 format. (BAB) */
  42. /* ***END PROLOGUE ZBUNI */
  43. /* COMPLEX CSCL,CSCR,CY,RZ,ST,S1,S2,Y,Z */
  44. /* ***FIRST EXECUTABLE STATEMENT ZBUNI */
  45. /* Parameter adjustments */
  46. --yi;
  47. --yr;
  48. /* Function Body */
  49. *nz = 0;
  50. ax = abs(*zr) * 1.7321;
  51. ay = abs(*zi);
  52. iform = 1;
  53. if (ay > ax) {
  54. iform = 2;
  55. }
  56. if (*nui == 0) {
  57. goto L60;
  58. }
  59. fnui = (double) (*nui);
  60. dfnu = *fnu + (*n - 1);
  61. gnu = dfnu + fnui;
  62. if (iform == 2) {
  63. goto L10;
  64. }
  65. /* ----------------------------------------------------------------------- */
  66. /* ASYMPTOTIC EXPANSION FOR I(FNU,Z) FOR LARGE FNU APPLIED IN */
  67. /* -PI/3.LE.ARG(Z).LE.PI/3 */
  68. /* ----------------------------------------------------------------------- */
  69. zuni1_(zr, zi, &gnu, kode, &c__2, cyr, cyi, &nw, nlast, fnul, tol, elim,
  70. alim);
  71. goto L20;
  72. L10:
  73. /* ----------------------------------------------------------------------- */
  74. /* ASYMPTOTIC EXPANSION FOR J(FNU,Z*EXP(M*HPI)) FOR LARGE FNU */
  75. /* APPLIED IN PI/3.LT.ABS(ARG(Z)).LE.PI/2 WHERE M=+I OR -I */
  76. /* AND HPI=PI/2 */
  77. /* ----------------------------------------------------------------------- */
  78. zuni2_(zr, zi, &gnu, kode, &c__2, cyr, cyi, &nw, nlast, fnul, tol, elim,
  79. alim);
  80. L20:
  81. if (nw < 0) {
  82. goto L50;
  83. }
  84. if (nw != 0) {
  85. goto L90;
  86. }
  87. str = zabs_(cyr, cyi);
  88. /* ---------------------------------------------------------------------- */
  89. /* SCALE BACKWARD RECURRENCE, BRY(3) IS DEFINED BUT NEVER USED */
  90. /* ---------------------------------------------------------------------- */
  91. bry[0] = d1mach_(1) * 1e3 / *tol;
  92. bry[1] = 1. / bry[0];
  93. bry[2] = bry[1];
  94. iflag = 2;
  95. ascle = bry[1];
  96. csclr = 1.;
  97. if (str > bry[0]) {
  98. goto L21;
  99. }
  100. iflag = 1;
  101. ascle = bry[0];
  102. csclr = 1. / *tol;
  103. goto L25;
  104. L21:
  105. if (str < bry[1]) {
  106. goto L25;
  107. }
  108. iflag = 3;
  109. ascle = bry[2];
  110. csclr = *tol;
  111. L25:
  112. cscrr = 1. / csclr;
  113. s1r = cyr[1] * csclr;
  114. s1i = cyi[1] * csclr;
  115. s2r = cyr[0] * csclr;
  116. s2i = cyi[0] * csclr;
  117. raz = 1. / zabs_(zr, zi);
  118. str = *zr * raz;
  119. sti = -(*zi) * raz;
  120. rzr = (str + str) * raz;
  121. rzi = (sti + sti) * raz;
  122. i__1 = *nui;
  123. for (i__ = 1; i__ <= i__1; ++i__) {
  124. str = s2r;
  125. sti = s2i;
  126. s2r = (dfnu + fnui) * (rzr * str - rzi * sti) + s1r;
  127. s2i = (dfnu + fnui) * (rzr * sti + rzi * str) + s1i;
  128. s1r = str;
  129. s1i = sti;
  130. fnui += -1.;
  131. if (iflag >= 3) {
  132. goto L30;
  133. }
  134. str = s2r * cscrr;
  135. sti = s2i * cscrr;
  136. c1r = abs(str);
  137. c1i = abs(sti);
  138. c1m = max(c1r,c1i);
  139. if (c1m <= ascle) {
  140. goto L30;
  141. }
  142. ++iflag;
  143. ascle = bry[iflag - 1];
  144. s1r *= cscrr;
  145. s1i *= cscrr;
  146. s2r = str;
  147. s2i = sti;
  148. csclr *= *tol;
  149. cscrr = 1. / csclr;
  150. s1r *= csclr;
  151. s1i *= csclr;
  152. s2r *= csclr;
  153. s2i *= csclr;
  154. L30:
  155. ;
  156. }
  157. yr[*n] = s2r * cscrr;
  158. yi[*n] = s2i * cscrr;
  159. if (*n == 1) {
  160. return 0;
  161. }
  162. nl = *n - 1;
  163. fnui = (double) nl;
  164. k = nl;
  165. i__1 = nl;
  166. for (i__ = 1; i__ <= i__1; ++i__) {
  167. str = s2r;
  168. sti = s2i;
  169. s2r = (*fnu + fnui) * (rzr * str - rzi * sti) + s1r;
  170. s2i = (*fnu + fnui) * (rzr * sti + rzi * str) + s1i;
  171. s1r = str;
  172. s1i = sti;
  173. str = s2r * cscrr;
  174. sti = s2i * cscrr;
  175. yr[k] = str;
  176. yi[k] = sti;
  177. fnui += -1.;
  178. --k;
  179. if (iflag >= 3) {
  180. goto L40;
  181. }
  182. c1r = abs(str);
  183. c1i = abs(sti);
  184. c1m = max(c1r,c1i);
  185. if (c1m <= ascle) {
  186. goto L40;
  187. }
  188. ++iflag;
  189. ascle = bry[iflag - 1];
  190. s1r *= cscrr;
  191. s1i *= cscrr;
  192. s2r = str;
  193. s2i = sti;
  194. csclr *= *tol;
  195. cscrr = 1. / csclr;
  196. s1r *= csclr;
  197. s1i *= csclr;
  198. s2r *= csclr;
  199. s2i *= csclr;
  200. L40:
  201. ;
  202. }
  203. return 0;
  204. L50:
  205. *nz = -1;
  206. if (nw == -2) {
  207. *nz = -2;
  208. }
  209. return 0;
  210. L60:
  211. if (iform == 2) {
  212. goto L70;
  213. }
  214. /* ----------------------------------------------------------------------- */
  215. /* ASYMPTOTIC EXPANSION FOR I(FNU,Z) FOR LARGE FNU APPLIED IN */
  216. /* -PI/3.LE.ARG(Z).LE.PI/3 */
  217. /* ----------------------------------------------------------------------- */
  218. zuni1_(zr, zi, fnu, kode, n, &yr[1], &yi[1], &nw, nlast, fnul, tol, elim,
  219. alim);
  220. goto L80;
  221. L70:
  222. /* ----------------------------------------------------------------------- */
  223. /* ASYMPTOTIC EXPANSION FOR J(FNU,Z*EXP(M*HPI)) FOR LARGE FNU */
  224. /* APPLIED IN PI/3.LT.ABS(ARG(Z)).LE.PI/2 WHERE M=+I OR -I */
  225. /* AND HPI=PI/2 */
  226. /* ----------------------------------------------------------------------- */
  227. zuni2_(zr, zi, fnu, kode, n, &yr[1], &yi[1], &nw, nlast, fnul, tol, elim,
  228. alim);
  229. L80:
  230. if (nw < 0) {
  231. goto L50;
  232. }
  233. *nz = nw;
  234. return 0;
  235. L90:
  236. *nlast = *n;
  237. return 0;
  238. } /* zbuni_ */