dasyik.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* dasyik.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__3 = 3;
  7. int dasyik_(double const *x, double const *fnu, integer const *kode,
  8. double *flgik, double *ra, double *arg, integer *in, double *y)
  9. {
  10. /* Initialized data */
  11. static double const con[2] = { .398942280401432678,1.25331413731550025 };
  12. static double const c__[65] = { -.208333333333333,.125,.334201388888889,
  13. -.401041666666667,.0703125,-1.02581259645062,1.84646267361111,
  14. -.8912109375,.0732421875,4.66958442342625,-11.207002616223,
  15. 8.78912353515625,-2.3640869140625,.112152099609375,
  16. -28.2120725582002,84.6362176746007,-91.81824154324,
  17. 42.5349987453885,-7.36879435947963,.227108001708984,
  18. 212.570130039217,-765.252468141182,1059.990452528,
  19. -699.579627376133,218.190511744212,-26.4914304869516,
  20. .572501420974731,-1919.45766231841,8061.72218173731,
  21. -13586.5500064341,11655.3933368645,-5305.6469786134,
  22. 1200.90291321635,-108.090919788395,1.72772750258446,
  23. 20204.2913309661,-96980.5983886375,192547.001232532,
  24. -203400.177280416,122200.464983017,-41192.6549688976,
  25. 7109.51430248936,-493.915304773088,6.07404200127348,
  26. -242919.187900551,1311763.61466298,-2998015.91853811,
  27. 3763271.2976564,-2813563.22658653,1268365.27332162,
  28. -331645.172484564,45218.7689813627,-2499.83048181121,
  29. 24.3805296995561,3284469.85307204,-19706819.1184322,
  30. 50952602.4926646,-74105148.2115327,66344512.274729,
  31. -37567176.6607634,13288767.1664218,-2785618.12808645,
  32. 308186.404612662,-13886.089753717,110.017140269247 };
  33. /* System generated locals */
  34. integer i__1, i__2;
  35. double d__1, d__2;
  36. /* Local variables */
  37. integer j, k, l;
  38. double t, z__, s1, s2, t2, ak, ap, fn;
  39. integer kk, jn;
  40. double gln, tol, etx, coef;
  41. /* ***BEGIN PROLOGUE DASYIK */
  42. /* ***SUBSIDIARY */
  43. /* ***PURPOSE Subsidiary to DBESI and DBESK */
  44. /* ***LIBRARY SLATEC */
  45. /* ***TYPE DOUBLE PRECISION (ASYIK-S, DASYIK-D) */
  46. /* ***AUTHOR Amos, D. E., (SNLA) */
  47. /* ***DESCRIPTION */
  48. /* DASYIK computes Bessel functions I and K */
  49. /* for arguments X.GT.0.0 and orders FNU.GE.35 */
  50. /* on FLGIK = 1 and FLGIK = -1 respectively. */
  51. /* INPUT */
  52. /* X - Argument, X.GT.0.0D0 */
  53. /* FNU - Order of first Bessel function */
  54. /* KODE - A parameter to indicate the scaling option */
  55. /* KODE=1 returns Y(I)= I/SUB(FNU+I-1)/(X), I=1,IN */
  56. /* or Y(I)= K/SUB(FNU+I-1)/(X), I=1,IN */
  57. /* on FLGIK = 1.0D0 or FLGIK = -1.0D0 */
  58. /* KODE=2 returns Y(I)=EXP(-X)*I/SUB(FNU+I-1)/(X), I=1,IN */
  59. /* or Y(I)=EXP( X)*K/SUB(FNU+I-1)/(X), I=1,IN */
  60. /* on FLGIK = 1.0D0 or FLGIK = -1.0D0 */
  61. /* FLGIK - Selection parameter for I or K FUNCTION */
  62. /* FLGIK = 1.0D0 gives the I function */
  63. /* FLGIK = -1.0D0 gives the K function */
  64. /* RA - SQRT(1.+Z*Z), Z=X/FNU */
  65. /* ARG - Argument of the leading exponential */
  66. /* IN - Number of functions desired, IN=1 or 2 */
  67. /* OUTPUT */
  68. /* Y - A vector whose first IN components contain the sequence */
  69. /* Abstract **** A double precision routine **** */
  70. /* DASYIK implements the uniform asymptotic expansion of */
  71. /* the I and K Bessel functions for FNU.GE.35 and real */
  72. /* X.GT.0.0D0. The forms are identical except for a change */
  73. /* in sign of some of the terms. This change in sign is */
  74. /* accomplished by means of the FLAG FLGIK = 1 or -1. */
  75. /* ***SEE ALSO DBESI, DBESK */
  76. /* ***ROUTINES CALLED D1MACH */
  77. /* ***REVISION HISTORY (YYMMDD) */
  78. /* 750101 DATE WRITTEN */
  79. /* 890531 Changed all specific intrinsics to generic. (WRB) */
  80. /* 890911 Removed unnecessary intrinsics. (WRB) */
  81. /* 891214 Prologue converted to Version 4.0 format. (BAB) */
  82. /* 900328 Added TYPE section. (WRB) */
  83. /* 910408 Updated the AUTHOR section. (WRB) */
  84. /* ***END PROLOGUE DASYIK */
  85. /* Parameter adjustments */
  86. --y;
  87. /* Function Body */
  88. /* ***FIRST EXECUTABLE STATEMENT DASYIK */
  89. tol = d1mach_(3);
  90. tol = max(tol,1e-15);
  91. fn = *fnu;
  92. z__ = (3. - *flgik) / 2.;
  93. kk = (integer) z__;
  94. i__1 = *in;
  95. for (jn = 1; jn <= i__1; ++jn) {
  96. if (jn == 1) {
  97. goto L10;
  98. }
  99. fn -= *flgik;
  100. z__ = *x / fn;
  101. *ra = sqrt(z__ * z__ + 1.);
  102. gln = log((*ra + 1.) / z__);
  103. etx = (double) (*kode - 1);
  104. t = *ra * (1. - etx) + etx / (z__ + *ra);
  105. *arg = fn * (t - gln) * *flgik;
  106. L10:
  107. coef = exp(*arg);
  108. t = 1. / *ra;
  109. t2 = t * t;
  110. t /= fn;
  111. t = f2c::d_sign(&t, flgik);
  112. s2 = 1.;
  113. ap = 1.;
  114. l = 0;
  115. for (k = 2; k <= 11; ++k) {
  116. ++l;
  117. s1 = c__[l - 1];
  118. i__2 = k;
  119. for (j = 2; j <= i__2; ++j) {
  120. ++l;
  121. s1 = s1 * t2 + c__[l - 1];
  122. /* L20: */
  123. }
  124. ap *= t;
  125. ak = ap * s1;
  126. s2 += ak;
  127. /* Computing MAX */
  128. d__1 = abs(ak), d__2 = abs(ap);
  129. if (max(d__1,d__2) < tol) {
  130. goto L40;
  131. }
  132. /* L30: */
  133. }
  134. L40:
  135. t = abs(t);
  136. y[jn] = s2 * coef * sqrt(t) * con[kk - 1];
  137. /* L50: */
  138. }
  139. return 0;
  140. } /* dasyik_ */