w_tgamma.c 1006 B

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 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. double tgamma(double x)
  18. {
  19. double y;
  20. int local_signgam;
  21. y = __ieee754_gamma_r(x, &local_signgam);
  22. if (local_signgam < 0)
  23. y = -y;
  24. #ifndef _IEEE_LIBM
  25. if (_LIB_VERSION == _IEEE_)
  26. return y;
  27. if (!isfinite(y) && isfinite(x)) {
  28. if (floor(x) == x && x <= 0.0)
  29. return __kernel_standard(x, x, 41); /* tgamma pole */
  30. return __kernel_standard(x, x, 40); /* tgamma overflow */
  31. }
  32. #endif
  33. return y;
  34. }
  35. libm_hidden_def(tgamma)