w_lgamma.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. libm_hidden_proto(signgam)
  19. double lgamma(double x)
  20. {
  21. #ifdef _IEEE_LIBM
  22. return __ieee754_lgamma_r(x,&signgam);
  23. #else
  24. double y;
  25. y = __ieee754_lgamma_r(x,&signgam);
  26. if(_LIB_VERSION == _IEEE_) return y;
  27. if(!isfinite(y)&&isfinite(x)) {
  28. if(floor(x)==x&&x<=0.0)
  29. return __kernel_standard(x,x,15); /* lgamma pole */
  30. else
  31. return __kernel_standard(x,x,14); /* lgamma overflow */
  32. } else
  33. return y;
  34. #endif
  35. }
  36. libm_hidden_def(lgamma)