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