Back to index

glibc  2.9
w_lgamma.c
Go to the documentation of this file.
00001 /* @(#)w_lgamma.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_lgamma.c,v 1.6 1995/05/10 20:49:24 jtc Exp $";
00015 #endif
00016 
00017 /* double lgamma(double x)
00018  * Return the logarithm of the Gamma function of x.
00019  *
00020  * Method: call __ieee754_lgamma_r
00021  */
00022 
00023 #include <math.h>
00024 #include "math_private.h"
00025 
00026 #ifdef __STDC__
00027        double __lgamma(double x)
00028 #else
00029        double __lgamma(x)
00030        double x;
00031 #endif
00032 {
00033 #ifdef _IEEE_LIBM
00034        return __ieee754_lgamma_r(x,&signgam);
00035 #else
00036         double y;
00037        int local_signgam = 0;
00038         y = __ieee754_lgamma_r(x,&local_signgam);
00039        if (_LIB_VERSION != _ISOC_)
00040          /* ISO C99 does not define the global variable.  */
00041          signgam = local_signgam;
00042         if(_LIB_VERSION == _IEEE_) return y;
00043         if(!__finite(y)&&__finite(x)) {
00044             if(__floor(x)==x&&x<=0.0)
00045                 return __kernel_standard(x,x,15); /* lgamma pole */
00046             else
00047                 return __kernel_standard(x,x,14); /* lgamma overflow */
00048         } else
00049             return y;
00050 #endif
00051 }
00052 weak_alias (__lgamma, lgamma)
00053 strong_alias (__lgamma, __gamma)
00054 weak_alias (__gamma, gamma)
00055 #ifdef NO_LONG_DOUBLE
00056 strong_alias (__lgamma, __lgammal)
00057 weak_alias (__lgamma, lgammal)
00058 strong_alias (__gamma, __gammal)
00059 weak_alias (__gamma, gammal)
00060 #endif