1LGAMMA(3) Linux Programmer's Manual LGAMMA(3)
2
3
4
6 lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, signgam - log
7 gamma function
8
10 #include <math.h>
11
12 double lgamma(double x);
13 float lgammaf(float x);
14 long double lgammal(long double x);
15
16 double lgamma_r(double x, int *signp);
17 float lgammaf_r(float x, int *signp);
18 long double lgammal_r(long double x, int *signp);
19
20 extern int signgam;
21
22 Link with -lm.
23
24 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
25
26 lgamma():
27 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE
28 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
29 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
30
31 lgammaf(), lgammal():
32 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
33 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
34 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
35
36 lgamma_r(), lgammaf_r(), lgammal_r():
37 /* Since glibc 2.19: */ _DEFAULT_SOURCE
38 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
39
40 signgam:
41 _XOPEN_SOURCE
42 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
43 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
44
46 For the definition of the Gamma function, see tgamma(3).
47
48 The lgamma(), lgammaf(), and lgammal() functions return the natural
49 logarithm of the absolute value of the Gamma function. The sign of the
50 Gamma function is returned in the external integer signgam declared in
51 <math.h>. It is 1 when the Gamma function is positive or zero, -1 when
52 it is negative.
53
54 Since using a constant location signgam is not thread-safe, the func‐
55 tions lgamma_r(), lgammaf_r(), and lgammal_r() have been introduced;
56 they return the sign via the argument signp.
57
59 On success, these functions return the natural logarithm of Gamma(x).
60
61 If x is a NaN, a NaN is returned.
62
63 If x is 1 or 2, +0 is returned.
64
65 If x is positive infinity or negative infinity, positive infinity is
66 returned.
67
68 If x is a nonpositive integer, a pole error occurs, and the functions
69 return +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL, respectively.
70
71 If the result overflows, a range error occurs, and the functions return
72 HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the correct math‐
73 ematical sign.
74
76 See math_error(7) for information on how to determine whether an error
77 has occurred when calling these functions.
78
79 The following errors can occur:
80
81 Pole error: x is a nonpositive integer
82 errno is set to ERANGE (but see BUGS). A divide-by-zero float‐
83 ing-point exception (FE_DIVBYZERO) is raised.
84
85 Range error: result overflow
86 errno is set to ERANGE. An overflow floating-point exception
87 (FE_OVERFLOW) is raised.
88
90 The lgamma() functions are specified in C99, POSIX.1-2001, and
91 POSIX.1-2008. signgam is specified in POSIX.1-2001 and POSIX.1-2008,
92 but not in C99. The lgamma_r() functions are nonstandard, but present
93 on several other systems.
94
96 In glibc 2.9 and earlier, when a pole error occurs, errno is set to
97 EDOM; instead of the POSIX-mandated ERANGE. Since version 2.10, glibc
98 does the right thing.
99
101 tgamma(3)
102
104 This page is part of release 5.12 of the Linux man-pages project. A
105 description of the project, information about reporting bugs, and the
106 latest version of this page, can be found at
107 https://www.kernel.org/doc/man-pages/.
108
109
110
111 2021-03-22 LGAMMA(3)