]>
Commit | Line | Data |
---|---|---|
f7eac6eb RM |
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 | |
30de3b18 | 8 | * software is freely granted, provided that this notice |
f7eac6eb RM |
9 | * is preserved. |
10 | * ==================================================== | |
11 | */ | |
12 | ||
13 | #if defined(LIBM_SCCS) && !defined(lint) | |
14 | static char rcsid[] = "$NetBSD: w_gamma.c,v 1.7 1995/11/20 22:06:43 jtc Exp $"; | |
15 | #endif | |
16 | ||
17 | /* double gamma(double x) | |
d705269e UD |
18 | * Return the logarithm of the Gamma function of x or the Gamma function of x, |
19 | * depending on the library mode. | |
f7eac6eb RM |
20 | */ |
21 | ||
22 | #include "math.h" | |
23 | #include "math_private.h" | |
24 | ||
f7eac6eb RM |
25 | #ifdef __STDC__ |
26 | double __gamma(double x) | |
27 | #else | |
28 | double __gamma(x) | |
29 | double x; | |
30 | #endif | |
31 | { | |
d705269e | 32 | double y; |
26b4d766 | 33 | #ifndef _IEEE_LIBM |
d705269e UD |
34 | if (_LIB_VERSION == _SVID_) |
35 | y = __ieee754_lgamma_r(x,&signgam); | |
36 | else | |
37 | { | |
26b4d766 | 38 | #endif |
5107cf1d UD |
39 | int local_signgam; |
40 | y = __ieee754_gamma_r(x,&local_signgam); | |
41 | if (local_signgam < 0) y = -y; | |
f7eac6eb | 42 | #ifdef _IEEE_LIBM |
d705269e | 43 | return y; |
f7eac6eb | 44 | #else |
d705269e UD |
45 | if(_LIB_VERSION == _IEEE_) return y; |
46 | } | |
f7eac6eb RM |
47 | if(!__finite(y)&&__finite(x)) { |
48 | if(__floor(x)==x&&x<=0.0) | |
49 | return __kernel_standard(x,x,41); /* gamma pole */ | |
50 | else | |
51 | return __kernel_standard(x,x,40); /* gamma overflow */ | |
52 | } else | |
53 | return y; | |
54 | #endif | |
30de3b18 | 55 | } |
f7eac6eb | 56 | weak_alias (__gamma, gamma) |
cccda09f UD |
57 | #ifdef NO_LONG_DOUBLE |
58 | strong_alias (__gamma, __gammal) | |
59 | weak_alias (__gamma, gammal) | |
60 | #endif |