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