d9lgmc.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* d9lgmc.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__15 = 15;
  7. static integer const c__3 = 3;
  8. static integer const c__1 = 1;
  9. static integer const c__2 = 2;
  10. /* Initialized data */
  11. static double const algmcs[15] = { .1666389480451863247205729650822,
  12. -1.384948176067563840732986059135e-5,
  13. 9.810825646924729426157171547487e-9,
  14. -1.809129475572494194263306266719e-11,
  15. 6.221098041892605227126015543416e-14,
  16. -3.399615005417721944303330599666e-16,
  17. 2.683181998482698748957538846666e-18,
  18. -2.868042435334643284144622399999e-20,
  19. 3.962837061046434803679306666666e-22,
  20. -6.831888753985766870111999999999e-24,
  21. 1.429227355942498147573333333333e-25,
  22. -3.547598158101070547199999999999e-27,
  23. 1.025680058010470912e-28,
  24. -3.401102254316748799999999999999e-30,
  25. 1.276642195630062933333333333333e-31 };
  26. static float const r__1 = (float) d1mach_(3);
  27. static integer const nalgm = initds_(algmcs, &c__15, &r__1);
  28. static double const xbig = 1. / sqrt(d1mach_(3));
  29. static double const xmax = exp((min(log(d1mach_(2) / 12.),
  30. -log(d1mach_(1) * 12.))));
  31. double d9lgmc_(double const *x)
  32. {
  33. /* System generated locals */
  34. double ret_val, d__1, d__2;
  35. /* ***BEGIN PROLOGUE D9LGMC */
  36. /* ***SUBSIDIARY */
  37. /* ***PURPOSE Compute the log Gamma correction factor so that */
  38. /* LOG(DGAMMA(X)) = LOG(SQRT(2*PI)) + (X-5.)*LOG(X) - X */
  39. /* + D9LGMC(X). */
  40. /* ***LIBRARY SLATEC (FNLIB) */
  41. /* ***CATEGORY C7E */
  42. /* ***TYPE DOUBLE PRECISION (R9LGMC-S, D9LGMC-D, C9LGMC-C) */
  43. /* ***KEYWORDS COMPLETE GAMMA FUNCTION, CORRECTION TERM, FNLIB, */
  44. /* LOG GAMMA, LOGARITHM, SPECIAL FUNCTIONS */
  45. /* ***AUTHOR Fullerton, W., (LANL) */
  46. /* ***DESCRIPTION */
  47. /* Compute the log gamma correction factor for X .GE. 10. so that */
  48. /* LOG (DGAMMA(X)) = LOG(SQRT(2*PI)) + (X-.5)*LOG(X) - X + D9lGMC(X) */
  49. /* Series for ALGM on the interval 0. to 1.00000E-02 */
  50. /* with weighted error 1.28E-31 */
  51. /* log weighted error 30.89 */
  52. /* significant figures required 29.81 */
  53. /* decimal places required 31.48 */
  54. /* ***REFERENCES (NONE) */
  55. /* ***ROUTINES CALLED D1MACH, DCSEVL, INITDS, XERMSG */
  56. /* ***REVISION HISTORY (YYMMDD) */
  57. /* 770601 DATE WRITTEN */
  58. /* 890531 Changed all specific intrinsics to generic. (WRB) */
  59. /* 890531 REVISION DATE from Version 3.2 */
  60. /* 891214 Prologue converted to Version 4.0 format. (BAB) */
  61. /* 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ) */
  62. /* 900720 Routine changed from user-callable to subsidiary. (WRB) */
  63. /* ***END PROLOGUE D9LGMC */
  64. /* ***FIRST EXECUTABLE STATEMENT D9LGMC */
  65. if (*x < 10.) {
  66. xermsg_("SLATEC", "D9LGMC", "X MUST BE GE 10", &c__1, &c__2, (ftnlen)
  67. 6, (ftnlen)6, (ftnlen)15);
  68. }
  69. if (*x >= xmax) {
  70. goto L20;
  71. }
  72. ret_val = 1. / (*x * 12.);
  73. if (*x < xbig) {
  74. /* Computing 2nd power */
  75. d__2 = 10. / *x;
  76. d__1 = d__2 * d__2 * 2. - 1.;
  77. ret_val = dcsevl_(&d__1, algmcs, &nalgm) / *x;
  78. }
  79. return ret_val;
  80. L20:
  81. ret_val = 0.;
  82. xermsg_("SLATEC", "D9LGMC", "X SO BIG D9LGMC UNDERFLOWS", &c__2, &c__1, (
  83. ftnlen)6, (ftnlen)6, (ftnlen)26);
  84. return ret_val;
  85. } /* d9lgmc_ */