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