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