w_tgamma.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* @(#)w_gamma.c 5.1 93/09/24 */
  2. /*
  3. * ====================================================
  4. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  5. *
  6. * Developed at SunPro, a Sun Microsystems, Inc. business.
  7. * Permission to use, copy, modify, and distribute this
  8. * software is freely granted, provided that this notice
  9. * is preserved.
  10. * ====================================================
  11. */
  12. /* double gamma(double x)
  13. * Return the logarithm of the Gamma function of x or the Gamma function of x,
  14. * depending on the library mode.
  15. */
  16. #include "math.h"
  17. #include "math_private.h"
  18. libm_hidden_proto(signgam)
  19. #ifdef __STDC__
  20. double tgamma(double x)
  21. #else
  22. double tgamma(x)
  23. double x;
  24. #endif
  25. {
  26. double y;
  27. int local_signgam;
  28. y = __ieee754_gamma_r(x,&local_signgam);
  29. if (local_signgam < 0) y = -y;
  30. #ifdef _IEEE_LIBM
  31. return y;
  32. #else
  33. if(_LIB_VERSION == _IEEE_) return y;
  34. if(!finite(y)&&finite(x)) {
  35. if(floor(x)==x&&x<=0.0)
  36. return __kernel_standard(x,x,41); /* tgamma pole */
  37. else
  38. return __kernel_standard(x,x,40); /* tgamma overflow */
  39. }
  40. return y;
  41. #endif
  42. }
  43. libm_hidden_def(tgamma)