dbesk1.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* dbesk1.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. static integer const c__16 = 16;
  8. static integer const c__2 = 2;
  9. static integer const c__1 = 1;
  10. /* Initialized data */
  11. static double const bk1cs[16] = { .025300227338947770532531120868533,
  12. -.35315596077654487566723831691801,
  13. -.12261118082265714823479067930042,
  14. -.0069757238596398643501812920296083,
  15. -1.7302889575130520630176507368979e-4,
  16. -2.4334061415659682349600735030164e-6,
  17. -2.2133876307347258558315252545126e-8,
  18. -1.4114883926335277610958330212608e-10,
  19. -6.6669016941993290060853751264373e-13,
  20. -2.4274498505193659339263196864853e-15,
  21. -7.023863479386287597178379712e-18,
  22. -1.6543275155100994675491029333333e-20,
  23. -3.2338347459944491991893333333333e-23,
  24. -5.3312750529265274999466666666666e-26,
  25. -7.5130407162157226666666666666666e-29,
  26. -9.1550857176541866666666666666666e-32 };
  27. static float const r__1 = (float) d1mach_(3) * (float).1;
  28. static integer const ntk1 = initds_(bk1cs, &c__16, &r__1);
  29. /* Computing MAX */
  30. static double const xmin = exp(max(+log(d1mach_(1)), -log(d1mach_(2))) + .01);
  31. static double const xsml = sqrt(d1mach_(3) * 4.);
  32. static double const xmaxt = -log(d1mach_(1));
  33. static double const xmax = xmaxt - xmaxt * .5 * log(xmaxt) / (xmaxt + .5);
  34. double dbesk1_(double const *x)
  35. {
  36. /* System generated locals */
  37. double d__1;
  38. /* Local variables */
  39. double y;
  40. /* ***BEGIN PROLOGUE DBESK1 */
  41. /* ***PURPOSE Compute the modified (hyperbolic) Bessel function of the */
  42. /* third kind of order one. */
  43. /* ***LIBRARY SLATEC (FNLIB) */
  44. /* ***CATEGORY C10B1 */
  45. /* ***TYPE DOUBLE PRECISION (BESK1-S, DBESK1-D) */
  46. /* ***KEYWORDS FNLIB, HYPERBOLIC BESSEL FUNCTION, */
  47. /* MODIFIED BESSEL FUNCTION, ORDER ONE, SPECIAL FUNCTIONS, */
  48. /* THIRD KIND */
  49. /* ***AUTHOR Fullerton, W., (LANL) */
  50. /* ***DESCRIPTION */
  51. /* DBESK1(X) calculates the double precision modified (hyperbolic) */
  52. /* Bessel function of the third kind of order one for double precision */
  53. /* argument X. The argument must be large enough that the result does */
  54. /* not overflow and small enough that the result does not underflow. */
  55. /* Series for BK1 on the interval 0. to 4.00000E+00 */
  56. /* with weighted error 9.16E-32 */
  57. /* log weighted error 31.04 */
  58. /* significant figures required 30.61 */
  59. /* decimal places required 31.64 */
  60. /* ***REFERENCES (NONE) */
  61. /* ***ROUTINES CALLED D1MACH, DBESI1, DBSK1E, DCSEVL, INITDS, XERMSG */
  62. /* ***REVISION HISTORY (YYMMDD) */
  63. /* 770701 DATE WRITTEN */
  64. /* 890531 Changed all specific intrinsics to generic. (WRB) */
  65. /* 890531 REVISION DATE from Version 3.2 */
  66. /* 891214 Prologue converted to Version 4.0 format. (BAB) */
  67. /* 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ) */
  68. /* ***END PROLOGUE DBESK1 */
  69. /* ***FIRST EXECUTABLE STATEMENT DBESK1 */
  70. if (*x <= 0.) {
  71. xermsg_("SLATEC", "DBESK1", "X IS ZERO OR NEGATIVE", &c__2, &c__2,
  72. (ftnlen)6, (ftnlen)6, (ftnlen)21);
  73. }
  74. if (*x > 2.) {
  75. if (*x > xmax) {
  76. xermsg_("SLATEC", "DBESK1", "X SO BIG K1 UNDERFLOWS", &c__1, &c__1,
  77. (ftnlen)6, (ftnlen)6, (ftnlen)22);
  78. return 0.;
  79. } else {
  80. return exp(-(*x)) * dbsk1e_(x);
  81. }
  82. } else {
  83. if (*x < xmin) {
  84. xermsg_("SLATEC", "DBESK1", "X SO SMALL K1 OVERFLOWS", &c__3, &c__2,
  85. (ftnlen)6, (ftnlen)6, (ftnlen)23);
  86. }
  87. y = 0.;
  88. if (*x > xsml) {
  89. y = *x * *x;
  90. }
  91. d__1 = y * .5 - 1.;
  92. return log(*x * .5) * dbesi1_(x) + (dcsevl_(&d__1, bk1cs, &ntk1) + .75) / *x;
  93. }
  94. } /* dbesk1_ */