zunik.cpp 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* zunik.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 zunik_(double *zrr, double *zri, double const *fnu,
  8. integer const *ikflg, integer const *ipmtr, double *tol, integer *init,
  9. double *phir, double *phii, double *zeta1r, double *
  10. zeta1i, double *zeta2r, double *zeta2i, double *sumr,
  11. double *sumi, double *cwrkr, double *cwrki)
  12. {
  13. /* Initialized data */
  14. static double const zeror = 0.;
  15. static double const zeroi = 0.;
  16. static double const coner = 1.;
  17. static double const conei = 0.;
  18. static double const con[2] = { .398942280401432678,1.25331413731550025 };
  19. static double const c__[120] = { 1.,-.208333333333333333,.125,
  20. .334201388888888889,-.401041666666666667,.0703125,
  21. -1.02581259645061728,1.84646267361111111,-.8912109375,.0732421875,
  22. 4.66958442342624743,-11.2070026162229938,8.78912353515625,
  23. -2.3640869140625,.112152099609375,-28.2120725582002449,
  24. 84.6362176746007346,-91.8182415432400174,42.5349987453884549,
  25. -7.3687943594796317,.227108001708984375,212.570130039217123,
  26. -765.252468141181642,1059.99045252799988,-699.579627376132541,
  27. 218.19051174421159,-26.4914304869515555,.572501420974731445,
  28. -1919.457662318407,8061.72218173730938,-13586.5500064341374,
  29. 11655.3933368645332,-5305.64697861340311,1200.90291321635246,
  30. -108.090919788394656,1.7277275025844574,20204.2913309661486,
  31. -96980.5983886375135,192547.001232531532,-203400.177280415534,
  32. 122200.46498301746,-41192.6549688975513,7109.51430248936372,
  33. -493.915304773088012,6.07404200127348304,-242919.187900551333,
  34. 1311763.6146629772,-2998015.91853810675,3763271.297656404,
  35. -2813563.22658653411,1268365.27332162478,-331645.172484563578,
  36. 45218.7689813627263,-2499.83048181120962,24.3805296995560639,
  37. 3284469.85307203782,-19706819.1184322269,50952602.4926646422,
  38. -74105148.2115326577,66344512.2747290267,-37567176.6607633513,
  39. 13288767.1664218183,-2785618.12808645469,308186.404612662398,
  40. -13886.0897537170405,110.017140269246738,-49329253.664509962,
  41. 325573074.185765749,-939462359.681578403,1553596899.57058006,
  42. -1621080552.10833708,1106842816.82301447,-495889784.275030309,
  43. 142062907.797533095,-24474062.7257387285,2243768.17792244943,
  44. -84005.4336030240853,551.335896122020586,814789096.118312115,
  45. -5866481492.05184723,18688207509.2958249,-34632043388.1587779,
  46. 41280185579.753974,-33026599749.8007231,17954213731.1556001,
  47. -6563293792.61928433,1559279864.87925751,-225105661.889415278,
  48. 17395107.5539781645,-549842.327572288687,3038.09051092238427,
  49. -14679261247.6956167,114498237732.02581,-399096175224.466498,
  50. 819218669548.577329,-1098375156081.22331,1008158106865.38209,
  51. -645364869245.376503,287900649906.150589,-87867072178.0232657,
  52. 17634730606.8349694,-2167164983.22379509,143157876.718888981,
  53. -3871833.44257261262,18257.7554742931747,286464035717.679043,
  54. -2406297900028.50396,9109341185239.89896,-20516899410934.4374,
  55. 30565125519935.3206,-31667088584785.1584,23348364044581.8409,
  56. -12320491305598.2872,4612725780849.13197,-1196552880196.1816,
  57. 205914503232.410016,-21822927757.5292237,1247009293.51271032,
  58. -29188388.1222208134,118838.426256783253 };
  59. /* System generated locals */
  60. integer i__1;
  61. double d__1, d__2;
  62. /* Local variables */
  63. integer i__, j, k, l;
  64. double ac, si, ti, sr, tr, t2i, t2r, rfn, sri, sti, zni, srr, str, znr;
  65. integer idum;
  66. double test, crfni, crfnr;
  67. /* ***BEGIN PROLOGUE ZUNIK */
  68. /* ***SUBSIDIARY */
  69. /* ***PURPOSE Subsidiary to ZBESI and ZBESK */
  70. /* ***LIBRARY SLATEC */
  71. /* ***TYPE ALL (CUNIK-A, ZUNIK-A) */
  72. /* ***AUTHOR Amos, D. E., (SNL) */
  73. /* ***DESCRIPTION */
  74. /* ZUNIK COMPUTES PARAMETERS FOR THE UNIFORM ASYMPTOTIC */
  75. /* EXPANSIONS OF THE I AND K FUNCTIONS ON IKFLG= 1 OR 2 */
  76. /* RESPECTIVELY BY */
  77. /* W(FNU,ZR) = PHI*EXP(ZETA)*SUM */
  78. /* WHERE ZETA=-ZETA1 + ZETA2 OR */
  79. /* ZETA1 - ZETA2 */
  80. /* THE FIRST CALL MUST HAVE INIT=0. SUBSEQUENT CALLS WITH THE */
  81. /* SAME ZR AND FNU WILL RETURN THE I OR K FUNCTION ON IKFLG= */
  82. /* 1 OR 2 WITH NO CHANGE IN INIT. CWRK IS A COMPLEX WORK */
  83. /* ARRAY. IPMTR=0 COMPUTES ALL PARAMETERS. IPMTR=1 COMPUTES PHI, */
  84. /* ZETA1,ZETA2. */
  85. /* ***SEE ALSO ZBESI, ZBESK */
  86. /* ***ROUTINES CALLED D1MACH, ZDIV, ZLOG, ZSQRT */
  87. /* ***REVISION HISTORY (YYMMDD) */
  88. /* 830501 DATE WRITTEN */
  89. /* 910415 Prologue converted to Version 4.0 format. (BAB) */
  90. /* 930122 Added EXTERNAL statement with ZLOG and ZSQRT. (RWC) */
  91. /* ***END PROLOGUE ZUNIK */
  92. /* COMPLEX CFN,CON,CONE,CRFN,CWRK,CZERO,PHI,S,SR,SUM,T,T2,ZETA1, */
  93. /* *ZETA2,ZN,ZR */
  94. /* Parameter adjustments */
  95. --cwrki;
  96. --cwrkr;
  97. /* Function Body */
  98. /* ***FIRST EXECUTABLE STATEMENT ZUNIK */
  99. if (*init != 0) {
  100. goto L40;
  101. }
  102. /* ----------------------------------------------------------------------- */
  103. /* INITIALIZE ALL VARIABLES */
  104. /* ----------------------------------------------------------------------- */
  105. rfn = 1. / *fnu;
  106. /* ----------------------------------------------------------------------- */
  107. /* OVERFLOW TEST (ZR/FNU TOO SMALL) */
  108. /* ----------------------------------------------------------------------- */
  109. test = d1mach_(1) * 1e3;
  110. ac = *fnu * test;
  111. if (abs(*zrr) > ac || abs(*zri) > ac) {
  112. goto L15;
  113. }
  114. *zeta1r = (d__1 = log(test), abs(d__1)) * 2. + *fnu;
  115. *zeta1i = 0.;
  116. *zeta2r = *fnu;
  117. *zeta2i = 0.;
  118. *phir = 1.;
  119. *phii = 0.;
  120. return 0;
  121. L15:
  122. tr = *zrr * rfn;
  123. ti = *zri * rfn;
  124. sr = coner + (tr * tr - ti * ti);
  125. si = conei + (tr * ti + ti * tr);
  126. zsqrt_(&sr, &si, &srr, &sri);
  127. str = coner + srr;
  128. sti = conei + sri;
  129. zdiv_(&str, &sti, &tr, &ti, &znr, &zni);
  130. zlog_(&znr, &zni, &str, &sti, &idum);
  131. *zeta1r = *fnu * str;
  132. *zeta1i = *fnu * sti;
  133. *zeta2r = *fnu * srr;
  134. *zeta2i = *fnu * sri;
  135. zdiv_(&coner, &conei, &srr, &sri, &tr, &ti);
  136. srr = tr * rfn;
  137. sri = ti * rfn;
  138. zsqrt_(&srr, &sri, &cwrkr[16], &cwrki[16]);
  139. *phir = cwrkr[16] * con[*ikflg - 1];
  140. *phii = cwrki[16] * con[*ikflg - 1];
  141. if (*ipmtr != 0) {
  142. return 0;
  143. }
  144. zdiv_(&coner, &conei, &sr, &si, &t2r, &t2i);
  145. cwrkr[1] = coner;
  146. cwrki[1] = conei;
  147. crfnr = coner;
  148. crfni = conei;
  149. ac = 1.;
  150. l = 1;
  151. for (k = 2; k <= 15; ++k) {
  152. sr = zeror;
  153. si = zeroi;
  154. i__1 = k;
  155. for (j = 1; j <= i__1; ++j) {
  156. ++l;
  157. str = sr * t2r - si * t2i + c__[l - 1];
  158. si = sr * t2i + si * t2r;
  159. sr = str;
  160. /* L10: */
  161. }
  162. str = crfnr * srr - crfni * sri;
  163. crfni = crfnr * sri + crfni * srr;
  164. crfnr = str;
  165. cwrkr[k] = crfnr * sr - crfni * si;
  166. cwrki[k] = crfnr * si + crfni * sr;
  167. ac *= rfn;
  168. test = (d__1 = cwrkr[k], abs(d__1)) + (d__2 = cwrki[k], abs(d__2));
  169. if (ac < *tol && test < *tol) {
  170. goto L30;
  171. }
  172. /* L20: */
  173. }
  174. k = 15;
  175. L30:
  176. *init = k;
  177. L40:
  178. if (*ikflg == 2) {
  179. goto L60;
  180. }
  181. /* ----------------------------------------------------------------------- */
  182. /* COMPUTE SUM FOR THE I FUNCTION */
  183. /* ----------------------------------------------------------------------- */
  184. sr = zeror;
  185. si = zeroi;
  186. i__1 = *init;
  187. for (i__ = 1; i__ <= i__1; ++i__) {
  188. sr += cwrkr[i__];
  189. si += cwrki[i__];
  190. /* L50: */
  191. }
  192. *sumr = sr;
  193. *sumi = si;
  194. *phir = cwrkr[16] * con[0];
  195. *phii = cwrki[16] * con[0];
  196. return 0;
  197. L60:
  198. /* ----------------------------------------------------------------------- */
  199. /* COMPUTE SUM FOR THE K FUNCTION */
  200. /* ----------------------------------------------------------------------- */
  201. sr = zeror;
  202. si = zeroi;
  203. tr = coner;
  204. i__1 = *init;
  205. for (i__ = 1; i__ <= i__1; ++i__) {
  206. sr += tr * cwrkr[i__];
  207. si += tr * cwrki[i__];
  208. tr = -tr;
  209. /* L70: */
  210. }
  211. *sumr = sr;
  212. *sumi = si;
  213. *phir = cwrkr[16] * con[1];
  214. *phii = cwrki[16] * con[1];
  215. return 0;
  216. } /* zunik_ */