w_lgamma.c 958 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * ====================================================
  3. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  4. *
  5. * Developed at SunPro, a Sun Microsystems, Inc. business.
  6. * Permission to use, copy, modify, and distribute this
  7. * software is freely granted, provided that this notice
  8. * is preserved.
  9. * ====================================================
  10. */
  11. /* double lgamma(double x)
  12. * Return the logarithm of the Gamma function of x.
  13. *
  14. * Method: call __ieee754_lgamma_r
  15. */
  16. #include <math.h>
  17. #include "math_private.h"
  18. double lgamma(double x)
  19. {
  20. #ifdef _IEEE_LIBM
  21. return __ieee754_lgamma_r(x, &signgam);
  22. #else
  23. double y = __ieee754_lgamma_r(x, &signgam);
  24. if (_LIB_VERSION == _IEEE_)
  25. return y;
  26. if (!isfinite(y) && isfinite(x)) {
  27. if (floor(x) == x && x <= 0.0)
  28. return __kernel_standard(x, x, 15); /* lgamma pole */
  29. return __kernel_standard(x, x, 14); /* lgamma overflow */
  30. }
  31. return y;
  32. #endif
  33. }
  34. libm_hidden_def(lgamma)