dbesk0.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* dbesk0.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__1 = 1;
  9. static integer const c__2 = 2;
  10. /* Initialized data */
  11. static double const bk0cs[16] = { -.0353273932339027687201140060063153,
  12. .344289899924628486886344927529213,
  13. .0359799365153615016265721303687231,
  14. .00126461541144692592338479508673447,
  15. 2.28621210311945178608269830297585e-5,
  16. 2.53479107902614945730790013428354e-7,
  17. 1.90451637722020885897214059381366e-9,
  18. 1.03496952576336245851008317853089e-11,
  19. 4.25981614279108257652445327170133e-14,
  20. 1.3744654358807508969423832544e-16,
  21. 3.57089652850837359099688597333333e-19,
  22. 7.63164366011643737667498666666666e-22,
  23. 1.36542498844078185908053333333333e-24,
  24. 2.07527526690666808319999999999999e-27,
  25. 2.7128142180729856e-30,
  26. 3.08259388791466666666666666666666e-33 };
  27. static float const r__1 = (float) d1mach_(3) * (float).1;
  28. static integer const ntk0 = initds_(bk0cs, &c__16, &r__1);
  29. static double const xsml = sqrt(d1mach_(3) * 4.);
  30. static double const xmaxt = -log(d1mach_(1));
  31. static double const xmax = xmaxt - xmaxt * .5 * log(xmaxt) / (xmaxt + .5);
  32. double dbesk0_(double const *x)
  33. {
  34. /* System generated locals */
  35. double ret_val, d__1;
  36. /* Local variables */
  37. double y;
  38. /* ***BEGIN PROLOGUE DBESK0 */
  39. /* ***PURPOSE Compute the modified (hyperbolic) Bessel function of the */
  40. /* third kind of order zero. */
  41. /* ***LIBRARY SLATEC (FNLIB) */
  42. /* ***CATEGORY C10B1 */
  43. /* ***TYPE DOUBLE PRECISION (BESK0-S, DBESK0-D) */
  44. /* ***KEYWORDS FNLIB, HYPERBOLIC BESSEL FUNCTION, */
  45. /* MODIFIED BESSEL FUNCTION, ORDER ZERO, SPECIAL FUNCTIONS, */
  46. /* THIRD KIND */
  47. /* ***AUTHOR Fullerton, W., (LANL) */
  48. /* ***DESCRIPTION */
  49. /* DBESK0(X) calculates the double precision modified (hyperbolic) */
  50. /* Bessel function of the third kind of order zero for double */
  51. /* precision argument X. The argument must be greater than zero */
  52. /* but not so large that the result underflows. */
  53. /* Series for BK0 on the interval 0. to 4.00000E+00 */
  54. /* with weighted error 3.08E-33 */
  55. /* log weighted error 32.51 */
  56. /* significant figures required 32.05 */
  57. /* decimal places required 33.11 */
  58. /* ***REFERENCES (NONE) */
  59. /* ***ROUTINES CALLED D1MACH, DBESI0, DBSK0E, DCSEVL, INITDS, XERMSG */
  60. /* ***REVISION HISTORY (YYMMDD) */
  61. /* 770701 DATE WRITTEN */
  62. /* 890531 Changed all specific intrinsics to generic. (WRB) */
  63. /* 890531 REVISION DATE from Version 3.2 */
  64. /* 891214 Prologue converted to Version 4.0 format. (BAB) */
  65. /* 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ) */
  66. /* ***END PROLOGUE DBESK0 */
  67. /* ***FIRST EXECUTABLE STATEMENT DBESK0 */
  68. if (*x <= 0.) {
  69. xermsg_("SLATEC", "DBESK0", "X IS ZERO OR NEGATIVE", &c__2, &c__2, (
  70. ftnlen)6, (ftnlen)6, (ftnlen)21);
  71. }
  72. if (*x > 2.) {
  73. goto L20;
  74. }
  75. y = 0.;
  76. if (*x > xsml) {
  77. y = *x * *x;
  78. }
  79. d__1 = y * .5 - 1.;
  80. ret_val = -log(*x * .5) * dbesi0_(x) - .25 + dcsevl_(&d__1, bk0cs, &ntk0);
  81. return ret_val;
  82. L20:
  83. ret_val = 0.;
  84. if (*x > xmax) {
  85. xermsg_("SLATEC", "DBESK0", "X SO BIG K0 UNDERFLOWS", &c__1, &c__1, (
  86. ftnlen)6, (ftnlen)6, (ftnlen)22);
  87. }
  88. if (*x > xmax) {
  89. return ret_val;
  90. }
  91. ret_val = exp(-(*x)) * dbsk0e_(x);
  92. return ret_val;
  93. } /* dbesk0_ */