Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  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.  
  13. /* double gamma(double x)
  14.  * Return  the logarithm of the Gamma function of x or the Gamma function of x,
  15.  * depending on the library mode.
  16.  */
  17.  
  18. #include "fdlibm.h"
  19.  
  20. #ifndef _DOUBLE_IS_32BITS
  21.  
  22. #ifdef __STDC__
  23.         double tgamma(double x)
  24. #else
  25.         double tgamma(x)
  26.         double x;
  27. #endif
  28. {
  29.         double y;
  30.         int local_signgam;
  31.         y = __ieee754_gamma_r(x,&local_signgam);
  32.         if (local_signgam < 0) y = -y;
  33. #ifdef _IEEE_LIBM
  34.         return y;
  35. #else
  36.         if(_LIB_VERSION == _IEEE_) return y;
  37.  
  38.         if(!finite(y)&&finite(x)) {
  39.           if(floor(x)==x&&x<=0.0)
  40.             return __kernel_standard(x,x,41); /* tgamma pole */
  41.           else
  42.             return __kernel_standard(x,x,40); /* tgamma overflow */
  43.         }
  44.         return y;
  45. #endif
  46. }
  47.  
  48. #endif /* defined(_DOUBLE_IS_32BITS) */
  49.