]>
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 | ||
f7eac6eb | 13 | /* double gamma(double x) |
d705269e UD |
14 | * Return the logarithm of the Gamma function of x or the Gamma function of x, |
15 | * depending on the library mode. | |
f7eac6eb RM |
16 | */ |
17 | ||
e47cc4e0 | 18 | #include <errno.h> |
9d13fb24 | 19 | #include <math.h> |
9277c064 | 20 | #include <math_private.h> |
f7eac6eb | 21 | |
0ac5ae23 UD |
22 | double |
23 | __tgamma(double x) | |
f7eac6eb | 24 | { |
e852e889 | 25 | int local_signgam; |
0ac5ae23 | 26 | double y = __ieee754_gamma_r(x,&local_signgam); |
cc60175e | 27 | |
d81f90cc | 28 | if(__glibc_unlikely (!isfinite (y) || y == 0) |
89faa034 | 29 | && (isfinite (x) || (isinf (x) && x < 0.0)) |
0ac5ae23 | 30 | && _LIB_VERSION != _IEEE_) { |
52495f29 UD |
31 | if (x == 0.0) |
32 | return __kernel_standard(x,x,50); /* tgamma pole */ | |
33 | else if(__floor(x)==x&&x<0.0) | |
34 | return __kernel_standard(x,x,41); /* tgamma domain */ | |
e47cc4e0 JM |
35 | else if (y == 0) |
36 | __set_errno (ERANGE); /* tgamma underflow */ | |
e852e889 UD |
37 | else |
38 | return __kernel_standard(x,x,40); /* tgamma overflow */ | |
39 | } | |
0ac5ae23 | 40 | return local_signgam < 0 ? -y : y; |
30de3b18 | 41 | } |
e852e889 | 42 | weak_alias (__tgamma, tgamma) |
cccda09f | 43 | #ifdef NO_LONG_DOUBLE |
e852e889 UD |
44 | strong_alias (__tgamma, __tgammal) |
45 | weak_alias (__tgamma, tgammal) | |
cccda09f | 46 | #endif |