w_tgamma.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 gamma(double x)
  12. * Return the logarithm of the Gamma function of x or the Gamma function of x,
  13. * depending on the library mode.
  14. */
  15. #include "math.h"
  16. #include "math_private.h"
  17. libm_hidden_proto(signgam)
  18. double tgamma(double x)
  19. {
  20. double y;
  21. int local_signgam;
  22. y = __ieee754_gamma_r(x,&local_signgam);
  23. if (local_signgam < 0) y = -y;
  24. #ifdef _IEEE_LIBM
  25. return y;
  26. #else
  27. if(_LIB_VERSION == _IEEE_) return y;
  28. if(!isfinite(y)&&isfinite(x)) {
  29. if(floor(x)==x&&x<=0.0)
  30. return __kernel_standard(x,x,41); /* tgamma pole */
  31. else
  32. return __kernel_standard(x,x,40); /* tgamma overflow */
  33. }
  34. return y;
  35. #endif
  36. }
  37. libm_hidden_def(tgamma)