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