dgamlm.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* dgamlm.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. int dgamlm_(double *xmin, double *xmax)
  9. {
  10. /* System generated locals */
  11. double d__1, d__2;
  12. /* Local variables */
  13. integer i__;
  14. double xln, xold;
  15. double alnbig, alnsml;
  16. /* ***BEGIN PROLOGUE DGAMLM */
  17. /* ***PURPOSE Compute the minimum and maximum bounds for the argument in */
  18. /* the Gamma function. */
  19. /* ***LIBRARY SLATEC (FNLIB) */
  20. /* ***CATEGORY C7A, R2 */
  21. /* ***TYPE DOUBLE PRECISION (GAMLIM-S, DGAMLM-D) */
  22. /* ***KEYWORDS COMPLETE GAMMA FUNCTION, FNLIB, LIMITS, SPECIAL FUNCTIONS */
  23. /* ***AUTHOR Fullerton, W., (LANL) */
  24. /* ***DESCRIPTION */
  25. /* Calculate the minimum and maximum legal bounds for X in gamma(X). */
  26. /* XMIN and XMAX are not the only bounds, but they are the only non- */
  27. /* trivial ones to calculate. */
  28. /* Output Arguments -- */
  29. /* XMIN double precision minimum legal value of X in gamma(X). Any */
  30. /* smaller value of X might result in underflow. */
  31. /* XMAX double precision maximum legal value of X in gamma(X). Any */
  32. /* larger value of X might cause overflow. */
  33. /* ***REFERENCES (NONE) */
  34. /* ***ROUTINES CALLED D1MACH, XERMSG */
  35. /* ***REVISION HISTORY (YYMMDD) */
  36. /* 770601 DATE WRITTEN */
  37. /* 890531 Changed all specific intrinsics to generic. (WRB) */
  38. /* 890531 REVISION DATE from Version 3.2 */
  39. /* 891214 Prologue converted to Version 4.0 format. (BAB) */
  40. /* 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ) */
  41. /* ***END PROLOGUE DGAMLM */
  42. /* ***FIRST EXECUTABLE STATEMENT DGAMLM */
  43. alnsml = log(d1mach_(1));
  44. *xmin = -alnsml;
  45. for (i__ = 1; i__ <= 10; ++i__) {
  46. xold = *xmin;
  47. xln = log(*xmin);
  48. *xmin -= *xmin * ((*xmin + .5) * xln - *xmin - .2258 + alnsml) / (*
  49. xmin * xln + .5);
  50. if ((d__1 = *xmin - xold, abs(d__1)) < .005) {
  51. goto L20;
  52. }
  53. /* L10: */
  54. }
  55. xermsg_("SLATEC", "DGAMLM", "UNABLE TO FIND XMIN", &c__1, &c__2, (ftnlen)
  56. 6, (ftnlen)6, (ftnlen)19);
  57. L20:
  58. *xmin = -(*xmin) + .01;
  59. alnbig = log(d1mach_(2));
  60. *xmax = alnbig;
  61. for (i__ = 1; i__ <= 10; ++i__) {
  62. xold = *xmax;
  63. xln = log(*xmax);
  64. *xmax -= *xmax * ((*xmax - .5) * xln - *xmax + .9189 - alnbig) / (*
  65. xmax * xln - .5);
  66. if ((d__1 = *xmax - xold, abs(d__1)) < .005) {
  67. goto L40;
  68. }
  69. /* L30: */
  70. }
  71. xermsg_("SLATEC", "DGAMLM", "UNABLE TO FIND XMAX", &c__2, &c__2, (ftnlen)
  72. 6, (ftnlen)6, (ftnlen)19);
  73. L40:
  74. *xmax += -.01;
  75. /* Computing MAX */
  76. d__1 = *xmin, d__2 = -(*xmax) + 1.;
  77. *xmin = max(d__1,d__2);
  78. return 0;
  79. } /* dgamlm_ */