1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
.\" <mtk.manpages@gmail.com>
.\"
.\" SPDX-License-Identifier: GPL-1.0-or-later
.\"
.\" based on glibc infopages
.\"
.TH lgamma 3 2024-05-02 "Linux man-pages (unreleased)"
.SH NAME
lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, signgam \-
log gamma function
.SH LIBRARY
Math library
.RI ( libm ", " \-lm )
.SH SYNOPSIS
.nf
.B #include <math.h>
.P
.BI "double lgamma(double " x );
.BI "float lgammaf(float " x );
.BI "long double lgammal(long double " x );
.P
.BI "double lgamma_r(double " x ", int *" signp );
.BI "float lgammaf_r(float " x ", int *" signp );
.BI "long double lgammal_r(long double " x ", int *" signp );
.P
.BI "extern int " signgam ;
.fi
.P
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
.P
.nf
.BR lgamma ():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
.fi
.P
.BR lgammaf (),
.BR lgammal ():
.nf
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
.fi
.P
.BR lgamma_r (),
.BR lgammaf_r (),
.BR lgammal_r ():
.nf
/* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
.fi
.P
.IR signgam :
.nf
_XOPEN_SOURCE
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
.fi
.SH DESCRIPTION
For the definition of the Gamma function, see
.BR tgamma (3).
.P
The
.BR lgamma (),
.BR lgammaf (),
and
.BR lgammal ()
functions return the natural logarithm of
the absolute value of the Gamma function.
The sign of the Gamma function is returned in the
external integer
.I signgam
declared in
.IR <math.h> .
It is 1 when the Gamma function is positive or zero, \-1
when it is negative.
.P
Since using a constant location
.I signgam
is not thread-safe, the functions
.BR lgamma_r (),
.BR lgammaf_r (),
and
.BR lgammal_r ()
have been introduced; they return the sign via the argument
.IR signp .
.SH RETURN VALUE
On success, these functions return the natural logarithm of Gamma(x).
.P
If
.I x
is a NaN, a NaN is returned.
.P
If
.I x
is 1 or 2, +0 is returned.
.P
If
.I x
is positive infinity or negative infinity,
positive infinity is returned.
.P
If
.I x
is a nonpositive integer,
a pole error occurs,
and the functions return
.RB + HUGE_VAL ,
.RB + HUGE_VALF ,
or
.RB + HUGE_VALL ,
respectively.
.P
If the result overflows,
a range error occurs,
.\" e.g., lgamma(DBL_MAX)
and the functions return
.BR HUGE_VAL ,
.BR HUGE_VALF ,
or
.BR HUGE_VALL ,
respectively, with the correct mathematical sign.
.SH ERRORS
See
.BR math_error (7)
for information on how to determine whether an error has occurred
when calling these functions.
.P
The following errors can occur:
.TP
Pole error: \fIx\fP is a nonpositive integer
.I errno
is set to
.B ERANGE
(but see BUGS).
A divide-by-zero floating-point exception
.RB ( FE_DIVBYZERO )
is raised.
.TP
Range error: result overflow
.I errno
is set to
.BR ERANGE .
An overflow floating-point exception
.RB ( FE_OVERFLOW )
is raised.
.\" glibc (as at 2.8) also supports an inexact
.\" exception for various cases.
.SH STANDARDS
.TP
.BR lgamma ()
.TQ
.BR lgammaf ()
.TQ
.BR lgammal ()
C11, POSIX.1-2008.
.TP
.I signgam
POSIX.1-2008.
.TP
.BR lgamma_r ()
.TQ
.BR lgammaf_r ()
.TQ
.BR lgammal_r ()
None.
.SH HISTORY
.TP
.BR lgamma ()
.TQ
.BR lgammaf ()
.TQ
.BR lgammal ()
C99, POSIX.1-2001.
.TP
.I signgam
POSIX.1-2001.
.TP
.BR lgamma_r ()
.TQ
.BR lgammaf_r ()
.TQ
.BR lgammal_r ()
None.
.SH BUGS
In glibc 2.9 and earlier,
.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6777
when a pole error occurs,
.I errno
is set to
.BR EDOM ;
instead of the POSIX-mandated
.BR ERANGE .
Since glibc 2.10, glibc does the right thing.
.SH SEE ALSO
.BR tgamma (3)
|