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