Back to index

glibc  2.9
w_tgamma.c
Go to the documentation of this file.
00001 /* @(#)w_gamma.c 5.1 93/09/24 */
00002 /*
00003  * ====================================================
00004  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00005  *
00006  * Developed at SunPro, a Sun Microsystems, Inc. business.
00007  * Permission to use, copy, modify, and distribute this
00008  * software is freely granted, provided that this notice
00009  * is preserved.
00010  * ====================================================
00011  */
00012 
00013 #if defined(LIBM_SCCS) && !defined(lint)
00014 static char rcsid[] = "$NetBSD: w_gamma.c,v 1.7 1995/11/20 22:06:43 jtc Exp $";
00015 #endif
00016 
00017 /* double gamma(double x)
00018  * Return  the logarithm of the Gamma function of x or the Gamma function of x,
00019  * depending on the library mode.
00020  */
00021 
00022 #include <math.h>
00023 #include "math_private.h"
00024 
00025 #ifdef __STDC__
00026        double __tgamma(double x)
00027 #else
00028        double __tgamma(x)
00029        double x;
00030 #endif
00031 {
00032         double y;
00033        int local_signgam;
00034        y = __ieee754_gamma_r(x,&local_signgam);
00035        if (local_signgam < 0) y = -y;
00036 #ifdef _IEEE_LIBM
00037        return y;
00038 #else
00039        if(_LIB_VERSION == _IEEE_) return y;
00040 
00041        if(!__finite(y)&&__finite(x)) {
00042          if (x == 0.0)
00043            return __kernel_standard(x,x,50); /* tgamma pole */
00044          else if(__floor(x)==x&&x<0.0)
00045            return __kernel_standard(x,x,41); /* tgamma domain */
00046          else
00047            return __kernel_standard(x,x,40); /* tgamma overflow */
00048        }
00049        return y;
00050 #endif
00051 }
00052 weak_alias (__tgamma, tgamma)
00053 #ifdef NO_LONG_DOUBLE
00054 strong_alias (__tgamma, __tgammal)
00055 weak_alias (__tgamma, tgammal)
00056 #endif