]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de) |
9981365e MK |
2 | .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
3 | .\" <mtk.manpages@gmail.com> | |
2297bf0e | 4 | .\" |
95fb8859 | 5 | .\" SPDX-License-Identifier: GPL-1.0-or-later |
9981365e | 6 | .\" |
fea681da MK |
7 | .\" based on glibc infopages |
8 | .\" | |
45186a5d | 9 | .TH LGAMMA 3 2021-03-22 "Linux man-pages (unreleased)" |
fea681da | 10 | .SH NAME |
cc4615cc MK |
11 | lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, signgam \- |
12 | log gamma function | |
77418438 AC |
13 | .SH LIBRARY |
14 | Math library | |
8fc3b2cf | 15 | .RI ( libm ", " \-lm ) |
fea681da MK |
16 | .SH SYNOPSIS |
17 | .nf | |
18 | .B #include <math.h> | |
68e4db0a | 19 | .PP |
fea681da | 20 | .BI "double lgamma(double " x ); |
fea681da | 21 | .BI "float lgammaf(float " x ); |
fea681da | 22 | .BI "long double lgammal(long double " x ); |
68e4db0a | 23 | .PP |
fea681da | 24 | .BI "double lgamma_r(double " x ", int *" signp ); |
fea681da | 25 | .BI "float lgammaf_r(float " x ", int *" signp ); |
fea681da | 26 | .BI "long double lgammal_r(long double " x ", int *" signp ); |
68e4db0a | 27 | .PP |
cc4615cc | 28 | .BI "extern int " signgam ; |
fea681da | 29 | .fi |
68e4db0a | 30 | .PP |
d39ad78f | 31 | .RS -4 |
cc4615cc MK |
32 | Feature Test Macro Requirements for glibc (see |
33 | .BR feature_test_macros (7)): | |
d39ad78f | 34 | .RE |
68e4db0a | 35 | .PP |
9d2adbae | 36 | .nf |
bb4abad3 | 37 | .BR lgamma (): |
5c10d2c5 | 38 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE |
9d2adbae MK |
39 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE |
40 | || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
41 | .fi | |
98c9347c | 42 | .PP |
cc4615cc MK |
43 | .BR lgammaf (), |
44 | .BR lgammal (): | |
9d2adbae | 45 | .nf |
5c10d2c5 | 46 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae MK |
47 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE |
48 | || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
49 | .fi | |
98c9347c | 50 | .PP |
cc4615cc MK |
51 | .BR lgamma_r (), |
52 | .BR lgammaf_r (), | |
53 | .BR lgammal_r (): | |
9d2adbae MK |
54 | .nf |
55 | /* Since glibc 2.19: */ _DEFAULT_SOURCE | |
56 | || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
57 | .fi | |
98c9347c | 58 | .PP |
cc4615cc | 59 | .IR signgam : |
9d2adbae MK |
60 | .nf |
61 | _XOPEN_SOURCE | |
62 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE | |
63 | || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
64 | .fi | |
fea681da MK |
65 | .SH DESCRIPTION |
66 | For the definition of the Gamma function, see | |
67 | .BR tgamma (3). | |
68 | .PP | |
60a90ecd | 69 | The |
5600f73a MK |
70 | .BR lgamma (), |
71 | .BR lgammaf (), | |
72 | and | |
73 | .BR lgammal () | |
74 | functions return the natural logarithm of | |
fea681da MK |
75 | the absolute value of the Gamma function. |
76 | The sign of the Gamma function is returned in the | |
022671eb MK |
77 | external integer |
78 | .I signgam | |
79 | declared in | |
fea681da MK |
80 | .IR <math.h> . |
81 | It is 1 when the Gamma function is positive or zero, \-1 | |
82 | when it is negative. | |
83 | .PP | |
84 | Since using a constant location | |
85 | .I signgam | |
60a90ecd | 86 | is not thread-safe, the functions |
853a2aba MK |
87 | .BR lgamma_r (), |
88 | .BR lgammaf_r (), | |
89 | and | |
90 | .BR lgammal_r () | |
91 | have been introduced; they return the sign via the argument | |
fea681da | 92 | .IR signp . |
bb4abad3 MK |
93 | .SH RETURN VALUE |
94 | On success, these functions return the natural logarithm of Gamma(x). | |
847e0d88 | 95 | .PP |
bb4abad3 MK |
96 | If |
97 | .I x | |
98 | is a NaN, a NaN is returned. | |
847e0d88 | 99 | .PP |
bb4abad3 MK |
100 | If |
101 | .I x | |
102 | is 1 or 2, +0 is returned. | |
847e0d88 | 103 | .PP |
bb4abad3 MK |
104 | If |
105 | .I x | |
106 | is positive infinity or negative infinity, | |
107 | positive infinity is returned. | |
847e0d88 | 108 | .PP |
bb4abad3 MK |
109 | If |
110 | .I x | |
657316c0 | 111 | is a nonpositive integer, |
efe294cb | 112 | a pole error occurs, |
bb4abad3 MK |
113 | and the functions return |
114 | .RB + HUGE_VAL , | |
115 | .RB + HUGE_VALF , | |
116 | or | |
117 | .RB + HUGE_VALL , | |
118 | respectively. | |
847e0d88 | 119 | .PP |
bb4abad3 | 120 | If the result overflows, |
efe294cb | 121 | a range error occurs, |
bb4abad3 MK |
122 | .\" e.g., lgamma(DBL_MAX) |
123 | and the functions return | |
2f0af33b | 124 | .BR HUGE_VAL , |
bb4abad3 MK |
125 | .BR HUGE_VALF , |
126 | or | |
127 | .BR HUGE_VALL , | |
128 | respectively, with the correct mathematical sign. | |
fea681da | 129 | .SH ERRORS |
bb4abad3 MK |
130 | See |
131 | .BR math_error (7) | |
132 | for information on how to determine whether an error has occurred | |
133 | when calling these functions. | |
134 | .PP | |
135 | The following errors can occur: | |
136 | .TP | |
657316c0 | 137 | Pole error: \fIx\fP is a nonpositive integer |
fea681da | 138 | .I errno |
bb4abad3 | 139 | is set to |
1ae6b2c7 | 140 | .B ERANGE |
bb4abad3 MK |
141 | (but see BUGS). |
142 | A divide-by-zero floating-point exception | |
143 | .RB ( FE_DIVBYZERO ) | |
144 | is raised. | |
145 | .TP | |
146 | Range error: result overflow | |
fea681da | 147 | .I errno |
bb4abad3 MK |
148 | is set to |
149 | .BR ERANGE . | |
150 | An overflow floating-point exception | |
151 | .RB ( FE_OVERFLOW ) | |
152 | is raised. | |
153 | .\" glibc (as at 2.8) also supports an inexact | |
154 | .\" exception for various cases. | |
3113c7f3 | 155 | .SH STANDARDS |
637d38e3 MK |
156 | The |
157 | .BR lgamma () | |
9a0216ac | 158 | functions are specified in C99, POSIX.1-2001, and POSIX.1-2008. |
637d38e3 | 159 | .I signgam |
9a0216ac | 160 | is specified in POSIX.1-2001 and POSIX.1-2008, but not in C99. |
637d38e3 MK |
161 | The |
162 | .BR lgamma_r () | |
c8f2dd47 | 163 | functions are nonstandard, but present on several other systems. |
bb4abad3 | 164 | .SH BUGS |
4e836144 | 165 | In glibc 2.9 and earlier, |
707a25b2 MK |
166 | .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6777 |
167 | when a pole error occurs, | |
bb4abad3 MK |
168 | .I errno |
169 | is set to | |
170 | .BR EDOM ; | |
707a25b2 | 171 | instead of the POSIX-mandated |
bb4abad3 | 172 | .BR ERANGE . |
707a25b2 | 173 | Since version 2.10, glibc does the right thing. |
47297adb | 174 | .SH SEE ALSO |
fea681da | 175 | .BR tgamma (3) |