zunk2.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. /* zunk2.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. static integer const c__0 = 0;
  9. int zunk2_(double *zr, double *zi, double const *fnu,
  10. integer const *kode, integer *mr, integer const *n, double *yr, double *
  11. yi, integer *nz, double *tol, double *elim, double *alim)
  12. {
  13. /* Initialized data */
  14. static double const zeror = 0.;
  15. static double const aic = 1.26551212348464539;
  16. static double const cipr[4] = { 1.,0.,-1.,0. };
  17. static double const cipi[4] = { 0.,-1.,0.,1. };
  18. static double const zeroi = 0.;
  19. static double const coner = 1.;
  20. static double const cr1r = 1.;
  21. static double const cr1i = 1.73205080756887729;
  22. static double const cr2r = -.5;
  23. static double const cr2i = -.866025403784438647;
  24. static double const hpi = 1.57079632679489662;
  25. static double const pi = 3.14159265358979324;
  26. /* System generated locals */
  27. integer i__1;
  28. /* Local variables. Some initialized to avoid -Wmaybe-uninitialized */
  29. integer i__, j, k, ib, ic;
  30. double fn;
  31. integer il, kk, in, nw;
  32. double yy, c1i, c2i, c2m, c1r, c2r, s1i, s2i, rs1, s1r, s2r, aii, ang,
  33. asc, car, cki, fnf;
  34. integer nai;
  35. double air;
  36. integer ifn;
  37. double csi, ckr;
  38. integer iuf;
  39. double cyi[2], fmr, sar, csr, sgn, zbi;
  40. integer inu;
  41. double bry[3], cyr[2], pti, sti, zbr, zni, rzi, ptr, zri, str, znr,
  42. rzr, zrr, daii, aarg;
  43. integer ndai;
  44. double dair, aphi, argi[2], cscl, phii[2], crsc, argr[2];
  45. integer idum;
  46. double phir[2], csrr[3], cssr[3], rast, razr;
  47. integer iflag = 0, kflag = 0;
  48. double argdi, ascle;
  49. integer kdflg;
  50. double phidi, argdr;
  51. integer ipard;
  52. double csgni, phidr, cspni, asumi[2], bsumi[2];
  53. double cspnr, asumr[2], bsumr[2];
  54. double zeta1i[2], zeta2i[2], zet1di, zet2di, zeta1r[2], zeta2r[2],
  55. zet1dr, zet2dr, asumdi, bsumdi, asumdr, bsumdr;
  56. /* ***BEGIN PROLOGUE ZUNK2 */
  57. /* ***SUBSIDIARY */
  58. /* ***PURPOSE Subsidiary to ZBESK */
  59. /* ***LIBRARY SLATEC */
  60. /* ***TYPE ALL (CUNK2-A, ZUNK2-A) */
  61. /* ***AUTHOR Amos, D. E., (SNL) */
  62. /* ***DESCRIPTION */
  63. /* ZUNK2 COMPUTES K(FNU,Z) AND ITS ANALYTIC CONTINUATION FROM THE */
  64. /* RIGHT HALF PLANE TO THE LEFT HALF PLANE BY MEANS OF THE */
  65. /* UNIFORM ASYMPTOTIC EXPANSIONS FOR H(KIND,FNU,ZN) AND J(FNU,ZN) */
  66. /* WHERE ZN IS IN THE RIGHT HALF PLANE, KIND=(3-MR)/2, MR=+1 OR */
  67. /* -1. HERE ZN=ZR*I OR -ZR*I WHERE ZR=Z IF Z IS IN THE RIGHT */
  68. /* HALF PLANE OR ZR=-Z IF Z IS IN THE LEFT HALF PLANE. MR INDIC- */
  69. /* ATES THE DIRECTION OF ROTATION FOR ANALYTIC CONTINUATION. */
  70. /* NZ=-1 MEANS AN OVERFLOW WILL OCCUR */
  71. /* ***SEE ALSO ZBESK */
  72. /* ***ROUTINES CALLED D1MACH, ZABS, ZAIRY, ZS1S2, ZUCHK, ZUNHJ */
  73. /* ***REVISION HISTORY (YYMMDD) */
  74. /* 830501 DATE WRITTEN */
  75. /* 910415 Prologue converted to Version 4.0 format. (BAB) */
  76. /* ***END PROLOGUE ZUNK2 */
  77. /* COMPLEX AI,ARG,ARGD,ASUM,ASUMD,BSUM,BSUMD,CFN,CI,CIP,CK,CONE,CRSC, */
  78. /* *CR1,CR2,CS,CSCL,CSGN,CSPN,CSR,CSS,CY,CZERO,C1,C2,DAI,PHI,PHID,RZ, */
  79. /* *S1,S2,Y,Z,ZB,ZETA1,ZETA1D,ZETA2,ZETA2D,ZN,ZR */
  80. /* Parameter adjustments */
  81. --yi;
  82. --yr;
  83. /* Function Body */
  84. /* ***FIRST EXECUTABLE STATEMENT ZUNK2 */
  85. kdflg = 1;
  86. *nz = 0;
  87. /* ----------------------------------------------------------------------- */
  88. /* EXP(-ALIM)=EXP(-ELIM)/TOL=APPROX. ONE PRECISION GREATER THAN */
  89. /* THE UNDERFLOW LIMIT */
  90. /* ----------------------------------------------------------------------- */
  91. cscl = 1. / *tol;
  92. crsc = *tol;
  93. cssr[0] = cscl;
  94. cssr[1] = coner;
  95. cssr[2] = crsc;
  96. csrr[0] = crsc;
  97. csrr[1] = coner;
  98. csrr[2] = cscl;
  99. bry[0] = d1mach_(1) * 1e3 / *tol;
  100. bry[1] = 1. / bry[0];
  101. bry[2] = d1mach_(2);
  102. zrr = *zr;
  103. zri = *zi;
  104. if (*zr >= 0.) {
  105. goto L10;
  106. }
  107. zrr = -(*zr);
  108. zri = -(*zi);
  109. L10:
  110. yy = zri;
  111. znr = zri;
  112. zni = -zrr;
  113. zbr = zrr;
  114. zbi = zri;
  115. inu = (integer) (*fnu);
  116. fnf = *fnu - inu;
  117. ang = -hpi * fnf;
  118. car = cos(ang);
  119. sar = sin(ang);
  120. c2r = hpi * sar;
  121. c2i = -hpi * car;
  122. kk = inu % 4 + 1;
  123. str = c2r * cipr[kk - 1] - c2i * cipi[kk - 1];
  124. sti = c2r * cipi[kk - 1] + c2i * cipr[kk - 1];
  125. csr = cr1r * str - cr1i * sti;
  126. csi = cr1r * sti + cr1i * str;
  127. if (yy > 0.) {
  128. goto L20;
  129. }
  130. znr = -znr;
  131. zbi = -zbi;
  132. L20:
  133. /* ----------------------------------------------------------------------- */
  134. /* K(FNU,Z) IS COMPUTED FROM H(2,FNU,-I*Z) WHERE Z IS IN THE FIRST */
  135. /* QUADRANT. FOURTH QUADRANT VALUES (YY.LE.0.0E0) ARE COMPUTED BY */
  136. /* CONJUGATION SINCE THE K FUNCTION IS REAL ON THE POSITIVE REAL AXIS */
  137. /* ----------------------------------------------------------------------- */
  138. j = 2;
  139. i__1 = *n;
  140. for (i__ = 1; i__ <= i__1; ++i__) {
  141. /* ----------------------------------------------------------------------- */
  142. /* J FLIP FLOPS BETWEEN 1 AND 2 IN J = 3 - J */
  143. /* ----------------------------------------------------------------------- */
  144. j = 3 - j;
  145. fn = *fnu + (i__ - 1);
  146. zunhj_(&znr, &zni, &fn, &c__0, tol, &phir[j - 1], &phii[j - 1], &argr[
  147. j - 1], &argi[j - 1], &zeta1r[j - 1], &zeta1i[j - 1], &zeta2r[
  148. j - 1], &zeta2i[j - 1], &asumr[j - 1], &asumi[j - 1], &bsumr[
  149. j - 1], &bsumi[j - 1]);
  150. if (*kode == 1) {
  151. goto L30;
  152. }
  153. str = zbr + zeta2r[j - 1];
  154. sti = zbi + zeta2i[j - 1];
  155. rast = fn / zabs_(&str, &sti);
  156. str = str * rast * rast;
  157. sti = -sti * rast * rast;
  158. s1r = zeta1r[j - 1] - str;
  159. s1i = zeta1i[j - 1] - sti;
  160. goto L40;
  161. L30:
  162. s1r = zeta1r[j - 1] - zeta2r[j - 1];
  163. s1i = zeta1i[j - 1] - zeta2i[j - 1];
  164. L40:
  165. /* ----------------------------------------------------------------------- */
  166. /* TEST FOR UNDERFLOW AND OVERFLOW */
  167. /* ----------------------------------------------------------------------- */
  168. rs1 = s1r;
  169. if (abs(rs1) > *elim) {
  170. goto L70;
  171. }
  172. if (kdflg == 1) {
  173. kflag = 2;
  174. }
  175. if (abs(rs1) < *alim) {
  176. goto L50;
  177. }
  178. /* ----------------------------------------------------------------------- */
  179. /* REFINE TEST AND SCALE */
  180. /* ----------------------------------------------------------------------- */
  181. aphi = zabs_(&phir[j - 1], &phii[j - 1]);
  182. aarg = zabs_(&argr[j - 1], &argi[j - 1]);
  183. rs1 = rs1 + log(aphi) - log(aarg) * .25 - aic;
  184. if (abs(rs1) > *elim) {
  185. goto L70;
  186. }
  187. if (kdflg == 1) {
  188. kflag = 1;
  189. }
  190. if (rs1 < 0.) {
  191. goto L50;
  192. }
  193. if (kdflg == 1) {
  194. kflag = 3;
  195. }
  196. L50:
  197. /* ----------------------------------------------------------------------- */
  198. /* SCALE S1 TO KEEP INTERMEDIATE ARITHMETIC ON SCALE NEAR */
  199. /* EXPONENT EXTREMES */
  200. /* ----------------------------------------------------------------------- */
  201. c2r = argr[j - 1] * cr2r - argi[j - 1] * cr2i;
  202. c2i = argr[j - 1] * cr2i + argi[j - 1] * cr2r;
  203. zairy_(&c2r, &c2i, &c__0, &c__2, &air, &aii, &nai, &idum);
  204. zairy_(&c2r, &c2i, &c__1, &c__2, &dair, &daii, &ndai, &idum);
  205. str = dair * bsumr[j - 1] - daii * bsumi[j - 1];
  206. sti = dair * bsumi[j - 1] + daii * bsumr[j - 1];
  207. ptr = str * cr2r - sti * cr2i;
  208. pti = str * cr2i + sti * cr2r;
  209. str = ptr + (air * asumr[j - 1] - aii * asumi[j - 1]);
  210. sti = pti + (air * asumi[j - 1] + aii * asumr[j - 1]);
  211. ptr = str * phir[j - 1] - sti * phii[j - 1];
  212. pti = str * phii[j - 1] + sti * phir[j - 1];
  213. s2r = ptr * csr - pti * csi;
  214. s2i = ptr * csi + pti * csr;
  215. str = exp(s1r) * cssr[kflag - 1];
  216. s1r = str * cos(s1i);
  217. s1i = str * sin(s1i);
  218. str = s2r * s1r - s2i * s1i;
  219. s2i = s1r * s2i + s2r * s1i;
  220. s2r = str;
  221. if (kflag != 1) {
  222. goto L60;
  223. }
  224. zuchk_(&s2r, &s2i, &nw, bry, tol);
  225. if (nw != 0) {
  226. goto L70;
  227. }
  228. L60:
  229. if (yy <= 0.) {
  230. s2i = -s2i;
  231. }
  232. cyr[kdflg - 1] = s2r;
  233. cyi[kdflg - 1] = s2i;
  234. yr[i__] = s2r * csrr[kflag - 1];
  235. yi[i__] = s2i * csrr[kflag - 1];
  236. str = csi;
  237. csi = -csr;
  238. csr = str;
  239. if (kdflg == 2) {
  240. goto L85;
  241. }
  242. kdflg = 2;
  243. goto L80;
  244. L70:
  245. if (rs1 > 0.) {
  246. goto L320;
  247. }
  248. /* ----------------------------------------------------------------------- */
  249. /* FOR ZR.LT.0.0, THE I FUNCTION TO BE ADDED WILL OVERFLOW */
  250. /* ----------------------------------------------------------------------- */
  251. if (*zr < 0.) {
  252. goto L320;
  253. }
  254. kdflg = 1;
  255. yr[i__] = zeror;
  256. yi[i__] = zeroi;
  257. ++(*nz);
  258. str = csi;
  259. csi = -csr;
  260. csr = str;
  261. if (i__ == 1) {
  262. goto L80;
  263. }
  264. if (yr[i__ - 1] == zeror && yi[i__ - 1] == zeroi) {
  265. goto L80;
  266. }
  267. yr[i__ - 1] = zeror;
  268. yi[i__ - 1] = zeroi;
  269. ++(*nz);
  270. L80:
  271. ;
  272. }
  273. i__ = *n;
  274. L85:
  275. razr = 1. / zabs_(&zrr, &zri);
  276. str = zrr * razr;
  277. sti = -zri * razr;
  278. rzr = (str + str) * razr;
  279. rzi = (sti + sti) * razr;
  280. ckr = fn * rzr;
  281. cki = fn * rzi;
  282. ib = i__ + 1;
  283. if (*n < ib) {
  284. goto L180;
  285. }
  286. /* ----------------------------------------------------------------------- */
  287. /* TEST LAST MEMBER FOR UNDERFLOW AND OVERFLOW. SET SEQUENCE TO ZERO */
  288. /* ON UNDERFLOW. */
  289. /* ----------------------------------------------------------------------- */
  290. fn = *fnu + (*n - 1);
  291. ipard = 1;
  292. if (*mr != 0) {
  293. ipard = 0;
  294. }
  295. zunhj_(&znr, &zni, &fn, &ipard, tol, &phidr, &phidi, &argdr, &argdi, &
  296. zet1dr, &zet1di, &zet2dr, &zet2di, &asumdr, &asumdi, &bsumdr, &
  297. bsumdi);
  298. if (*kode == 1) {
  299. goto L90;
  300. }
  301. str = zbr + zet2dr;
  302. sti = zbi + zet2di;
  303. rast = fn / zabs_(&str, &sti);
  304. str = str * rast * rast;
  305. sti = -sti * rast * rast;
  306. s1r = zet1dr - str;
  307. s1i = zet1di - sti;
  308. goto L100;
  309. L90:
  310. s1r = zet1dr - zet2dr;
  311. s1i = zet1di - zet2di;
  312. L100:
  313. rs1 = s1r;
  314. if (abs(rs1) > *elim) {
  315. goto L105;
  316. }
  317. if (abs(rs1) < *alim) {
  318. goto L120;
  319. }
  320. /* ----------------------------------------------------------------------- */
  321. /* REFINE ESTIMATE AND TEST */
  322. /* ----------------------------------------------------------------------- */
  323. aphi = zabs_(&phidr, &phidi);
  324. rs1 += log(aphi);
  325. if (abs(rs1) < *elim) {
  326. goto L120;
  327. }
  328. L105:
  329. if (rs1 > 0.) {
  330. goto L320;
  331. }
  332. /* ----------------------------------------------------------------------- */
  333. /* FOR ZR.LT.0.0, THE I FUNCTION TO BE ADDED WILL OVERFLOW */
  334. /* ----------------------------------------------------------------------- */
  335. if (*zr < 0.) {
  336. goto L320;
  337. }
  338. *nz = *n;
  339. i__1 = *n;
  340. for (i__ = 1; i__ <= i__1; ++i__) {
  341. yr[i__] = zeror;
  342. yi[i__] = zeroi;
  343. /* L106: */
  344. }
  345. return 0;
  346. L120:
  347. s1r = cyr[0];
  348. s1i = cyi[0];
  349. s2r = cyr[1];
  350. s2i = cyi[1];
  351. c1r = csrr[kflag - 1];
  352. ascle = bry[kflag - 1];
  353. i__1 = *n;
  354. for (i__ = ib; i__ <= i__1; ++i__) {
  355. c2r = s2r;
  356. c2i = s2i;
  357. s2r = ckr * c2r - cki * c2i + s1r;
  358. s2i = ckr * c2i + cki * c2r + s1i;
  359. s1r = c2r;
  360. s1i = c2i;
  361. ckr += rzr;
  362. cki += rzi;
  363. c2r = s2r * c1r;
  364. c2i = s2i * c1r;
  365. yr[i__] = c2r;
  366. yi[i__] = c2i;
  367. if (kflag >= 3) {
  368. goto L130;
  369. }
  370. str = abs(c2r);
  371. sti = abs(c2i);
  372. c2m = max(str,sti);
  373. if (c2m <= ascle) {
  374. goto L130;
  375. }
  376. ++kflag;
  377. ascle = bry[kflag - 1];
  378. s1r *= c1r;
  379. s1i *= c1r;
  380. s2r = c2r;
  381. s2i = c2i;
  382. s1r *= cssr[kflag - 1];
  383. s1i *= cssr[kflag - 1];
  384. s2r *= cssr[kflag - 1];
  385. s2i *= cssr[kflag - 1];
  386. c1r = csrr[kflag - 1];
  387. L130:
  388. ;
  389. }
  390. L180:
  391. if (*mr == 0) {
  392. return 0;
  393. }
  394. /* ----------------------------------------------------------------------- */
  395. /* ANALYTIC CONTINUATION FOR RE(Z).LT.0.0D0 */
  396. /* ----------------------------------------------------------------------- */
  397. *nz = 0;
  398. fmr = (double) (*mr);
  399. sgn = -f2c::d_sign(&pi, &fmr);
  400. /* ----------------------------------------------------------------------- */
  401. /* CSPN AND CSGN ARE COEFF OF K AND I FUNCTIONS RESP. */
  402. /* ----------------------------------------------------------------------- */
  403. csgni = sgn;
  404. if (yy <= 0.) {
  405. csgni = -csgni;
  406. }
  407. ifn = inu + *n - 1;
  408. ang = fnf * sgn;
  409. cspnr = cos(ang);
  410. cspni = sin(ang);
  411. if (ifn % 2 == 0) {
  412. goto L190;
  413. }
  414. cspnr = -cspnr;
  415. cspni = -cspni;
  416. L190:
  417. /* ----------------------------------------------------------------------- */
  418. /* CS=COEFF OF THE J FUNCTION TO GET THE I FUNCTION. I(FNU,Z) IS */
  419. /* COMPUTED FROM EXP(I*FNU*HPI)*J(FNU,-I*Z) WHERE Z IS IN THE FIRST */
  420. /* QUADRANT. FOURTH QUADRANT VALUES (YY.LE.0.0E0) ARE COMPUTED BY */
  421. /* CONJUGATION SINCE THE I FUNCTION IS REAL ON THE POSITIVE REAL AXIS */
  422. /* ----------------------------------------------------------------------- */
  423. csr = sar * csgni;
  424. csi = car * csgni;
  425. in = ifn % 4 + 1;
  426. c2r = cipr[in - 1];
  427. c2i = cipi[in - 1];
  428. str = csr * c2r + csi * c2i;
  429. csi = -csr * c2i + csi * c2r;
  430. csr = str;
  431. asc = bry[0];
  432. iuf = 0;
  433. kk = *n;
  434. kdflg = 1;
  435. --ib;
  436. ic = ib - 1;
  437. i__1 = *n;
  438. for (k = 1; k <= i__1; ++k) {
  439. fn = *fnu + (kk - 1);
  440. /* ----------------------------------------------------------------------- */
  441. /* LOGIC TO SORT OUT CASES WHOSE PARAMETERS WERE SET FOR THE K */
  442. /* FUNCTION ABOVE */
  443. /* ----------------------------------------------------------------------- */
  444. if (*n > 2) {
  445. goto L175;
  446. }
  447. L172:
  448. phidr = phir[j - 1];
  449. phidi = phii[j - 1];
  450. argdr = argr[j - 1];
  451. argdi = argi[j - 1];
  452. zet1dr = zeta1r[j - 1];
  453. zet1di = zeta1i[j - 1];
  454. zet2dr = zeta2r[j - 1];
  455. zet2di = zeta2i[j - 1];
  456. asumdr = asumr[j - 1];
  457. asumdi = asumi[j - 1];
  458. bsumdr = bsumr[j - 1];
  459. bsumdi = bsumi[j - 1];
  460. j = 3 - j;
  461. goto L210;
  462. L175:
  463. if (kk == *n && ib < *n) {
  464. goto L210;
  465. }
  466. if (kk == ib || kk == ic) {
  467. goto L172;
  468. }
  469. zunhj_(&znr, &zni, &fn, &c__0, tol, &phidr, &phidi, &argdr, &argdi, &
  470. zet1dr, &zet1di, &zet2dr, &zet2di, &asumdr, &asumdi, &bsumdr,
  471. &bsumdi);
  472. L210:
  473. if (*kode == 1) {
  474. goto L220;
  475. }
  476. str = zbr + zet2dr;
  477. sti = zbi + zet2di;
  478. rast = fn / zabs_(&str, &sti);
  479. str = str * rast * rast;
  480. sti = -sti * rast * rast;
  481. s1r = -zet1dr + str;
  482. s1i = -zet1di + sti;
  483. goto L230;
  484. L220:
  485. s1r = -zet1dr + zet2dr;
  486. s1i = -zet1di + zet2di;
  487. L230:
  488. /* ----------------------------------------------------------------------- */
  489. /* TEST FOR UNDERFLOW AND OVERFLOW */
  490. /* ----------------------------------------------------------------------- */
  491. rs1 = s1r;
  492. if (abs(rs1) > *elim) {
  493. goto L280;
  494. }
  495. if (kdflg == 1) {
  496. iflag = 2;
  497. }
  498. if (abs(rs1) < *alim) {
  499. goto L240;
  500. }
  501. /* ----------------------------------------------------------------------- */
  502. /* REFINE TEST AND SCALE */
  503. /* ----------------------------------------------------------------------- */
  504. aphi = zabs_(&phidr, &phidi);
  505. aarg = zabs_(&argdr, &argdi);
  506. rs1 = rs1 + log(aphi) - log(aarg) * .25 - aic;
  507. if (abs(rs1) > *elim) {
  508. goto L280;
  509. }
  510. if (kdflg == 1) {
  511. iflag = 1;
  512. }
  513. if (rs1 < 0.) {
  514. goto L240;
  515. }
  516. if (kdflg == 1) {
  517. iflag = 3;
  518. }
  519. L240:
  520. zairy_(&argdr, &argdi, &c__0, &c__2, &air, &aii, &nai, &idum);
  521. zairy_(&argdr, &argdi, &c__1, &c__2, &dair, &daii, &ndai, &idum);
  522. str = dair * bsumdr - daii * bsumdi;
  523. sti = dair * bsumdi + daii * bsumdr;
  524. str += air * asumdr - aii * asumdi;
  525. sti += air * asumdi + aii * asumdr;
  526. ptr = str * phidr - sti * phidi;
  527. pti = str * phidi + sti * phidr;
  528. s2r = ptr * csr - pti * csi;
  529. s2i = ptr * csi + pti * csr;
  530. str = exp(s1r) * cssr[iflag - 1];
  531. s1r = str * cos(s1i);
  532. s1i = str * sin(s1i);
  533. str = s2r * s1r - s2i * s1i;
  534. s2i = s2r * s1i + s2i * s1r;
  535. s2r = str;
  536. if (iflag != 1) {
  537. goto L250;
  538. }
  539. zuchk_(&s2r, &s2i, &nw, bry, tol);
  540. if (nw == 0) {
  541. goto L250;
  542. }
  543. s2r = zeror;
  544. s2i = zeroi;
  545. L250:
  546. if (yy <= 0.) {
  547. s2i = -s2i;
  548. }
  549. cyr[kdflg - 1] = s2r;
  550. cyi[kdflg - 1] = s2i;
  551. c2r = s2r;
  552. c2i = s2i;
  553. s2r *= csrr[iflag - 1];
  554. s2i *= csrr[iflag - 1];
  555. /* ----------------------------------------------------------------------- */
  556. /* ADD I AND K FUNCTIONS, K SEQUENCE IN Y(I), I=1,N */
  557. /* ----------------------------------------------------------------------- */
  558. s1r = yr[kk];
  559. s1i = yi[kk];
  560. if (*kode == 1) {
  561. goto L270;
  562. }
  563. zs1s2_(&zrr, &zri, &s1r, &s1i, &s2r, &s2i, &nw, &asc, alim, &iuf);
  564. *nz += nw;
  565. L270:
  566. yr[kk] = s1r * cspnr - s1i * cspni + s2r;
  567. yi[kk] = s1r * cspni + s1i * cspnr + s2i;
  568. --kk;
  569. cspnr = -cspnr;
  570. cspni = -cspni;
  571. str = csi;
  572. csi = -csr;
  573. csr = str;
  574. if (c2r != 0. || c2i != 0.) {
  575. goto L255;
  576. }
  577. kdflg = 1;
  578. goto L290;
  579. L255:
  580. if (kdflg == 2) {
  581. goto L295;
  582. }
  583. kdflg = 2;
  584. goto L290;
  585. L280:
  586. if (rs1 > 0.) {
  587. goto L320;
  588. }
  589. s2r = zeror;
  590. s2i = zeroi;
  591. goto L250;
  592. L290:
  593. ;
  594. }
  595. k = *n;
  596. L295:
  597. il = *n - k;
  598. if (il == 0) {
  599. return 0;
  600. }
  601. /* ----------------------------------------------------------------------- */
  602. /* RECUR BACKWARD FOR REMAINDER OF I SEQUENCE AND ADD IN THE */
  603. /* K FUNCTIONS, SCALING THE I SEQUENCE DURING RECURRENCE TO KEEP */
  604. /* INTERMEDIATE ARITHMETIC ON SCALE NEAR EXPONENT EXTREMES. */
  605. /* ----------------------------------------------------------------------- */
  606. s1r = cyr[0];
  607. s1i = cyi[0];
  608. s2r = cyr[1];
  609. s2i = cyi[1];
  610. csr = csrr[iflag - 1];
  611. ascle = bry[iflag - 1];
  612. fn = (double) (inu + il);
  613. i__1 = il;
  614. for (i__ = 1; i__ <= i__1; ++i__) {
  615. c2r = s2r;
  616. c2i = s2i;
  617. s2r = s1r + (fn + fnf) * (rzr * c2r - rzi * c2i);
  618. s2i = s1i + (fn + fnf) * (rzr * c2i + rzi * c2r);
  619. s1r = c2r;
  620. s1i = c2i;
  621. fn += -1.;
  622. c2r = s2r * csr;
  623. c2i = s2i * csr;
  624. ckr = c2r;
  625. cki = c2i;
  626. c1r = yr[kk];
  627. c1i = yi[kk];
  628. if (*kode == 1) {
  629. goto L300;
  630. }
  631. zs1s2_(&zrr, &zri, &c1r, &c1i, &c2r, &c2i, &nw, &asc, alim, &iuf);
  632. *nz += nw;
  633. L300:
  634. yr[kk] = c1r * cspnr - c1i * cspni + c2r;
  635. yi[kk] = c1r * cspni + c1i * cspnr + c2i;
  636. --kk;
  637. cspnr = -cspnr;
  638. cspni = -cspni;
  639. if (iflag >= 3) {
  640. goto L310;
  641. }
  642. c2r = abs(ckr);
  643. c2i = abs(cki);
  644. c2m = max(c2r,c2i);
  645. if (c2m <= ascle) {
  646. goto L310;
  647. }
  648. ++iflag;
  649. ascle = bry[iflag - 1];
  650. s1r *= csr;
  651. s1i *= csr;
  652. s2r = ckr;
  653. s2i = cki;
  654. s1r *= cssr[iflag - 1];
  655. s1i *= cssr[iflag - 1];
  656. s2r *= cssr[iflag - 1];
  657. s2i *= cssr[iflag - 1];
  658. csr = csrr[iflag - 1];
  659. L310:
  660. ;
  661. }
  662. return 0;
  663. L320:
  664. *nz = -1;
  665. return 0;
  666. } /* zunk2_ */