Blame man3/lgamma.3

Packit 7cfc04
.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
Packit 7cfc04
.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
Packit 7cfc04
.\"     <mtk.manpages@gmail.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
Packit 7cfc04
.\" Distributed under GPL
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" based on glibc infopages
Packit 7cfc04
.\"
Packit 7cfc04
.TH LGAMMA 3 2017-09-15 "" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, signgam \-
Packit 7cfc04
log gamma function
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <math.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "double lgamma(double " x );
Packit 7cfc04
.BI "float lgammaf(float " x );
Packit 7cfc04
.BI "long double lgammal(long double " x );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "double lgamma_r(double " x ", int *" signp );
Packit 7cfc04
.BI "float lgammaf_r(float " x ", int *" signp );
Packit 7cfc04
.BI "long double lgammal_r(long double " x ", int *" signp );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "extern int " signgam ;
Packit 7cfc04
.fi
Packit 7cfc04
.PP
Packit 7cfc04
Link with \fI\-lm\fP.
Packit 7cfc04
.PP
Packit 7cfc04
.in -4n
Packit 7cfc04
Feature Test Macro Requirements for glibc (see
Packit 7cfc04
.BR feature_test_macros (7)):
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
.ad l
Packit 7cfc04
.BR lgamma ():
Packit 7cfc04
.RS 4
Packit 7cfc04
_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE
Packit 7cfc04
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
Packit 7cfc04
    || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
Packit 7cfc04
.RE
Packit 7cfc04
.br
Packit 7cfc04
.BR lgammaf (),
Packit 7cfc04
.BR lgammal ():
Packit 7cfc04
.RS 4
Packit 7cfc04
_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
Packit 7cfc04
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
Packit 7cfc04
    || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
Packit 7cfc04
.RE
Packit 7cfc04
.BR lgamma_r (),
Packit 7cfc04
.BR lgammaf_r (),
Packit 7cfc04
.BR lgammal_r ():
Packit 7cfc04
.RS 4
Packit 7cfc04
/* Since glibc 2.19: */ _DEFAULT_SOURCE
Packit 7cfc04
    || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
Packit 7cfc04
.RE
Packit 7cfc04
.IR signgam :
Packit 7cfc04
.RS 4
Packit 7cfc04
_XOPEN_SOURCE
Packit 7cfc04
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
Packit 7cfc04
    || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
Packit 7cfc04
.RE
Packit 7cfc04
.ad b
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
For the definition of the Gamma function, see
Packit 7cfc04
.BR tgamma (3).
Packit 7cfc04
.PP
Packit 7cfc04
The
Packit 7cfc04
.BR lgamma (),
Packit 7cfc04
.BR lgammaf (),
Packit 7cfc04
and
Packit 7cfc04
.BR lgammal ()
Packit 7cfc04
functions return the natural logarithm of
Packit 7cfc04
the absolute value of the Gamma function.
Packit 7cfc04
The sign of the Gamma function is returned in the
Packit 7cfc04
external integer
Packit 7cfc04
.I signgam
Packit 7cfc04
declared in
Packit 7cfc04
.IR <math.h> .
Packit 7cfc04
It is 1 when the Gamma function is positive or zero, \-1
Packit 7cfc04
when it is negative.
Packit 7cfc04
.PP
Packit 7cfc04
Since using a constant location
Packit 7cfc04
.I signgam
Packit 7cfc04
is not thread-safe, the functions
Packit 7cfc04
.BR lgamma_r (),
Packit 7cfc04
.BR lgammaf_r (),
Packit 7cfc04
and
Packit 7cfc04
.BR lgammal_r ()
Packit 7cfc04
have been introduced; they return the sign via the argument
Packit 7cfc04
.IR signp .
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success, these functions return the natural logarithm of Gamma(x).
Packit 7cfc04
.PP
Packit 7cfc04
If
Packit 7cfc04
.I x
Packit 7cfc04
is a NaN, a NaN is returned.
Packit 7cfc04
.PP
Packit 7cfc04
If
Packit 7cfc04
.I x
Packit 7cfc04
is 1 or 2, +0 is returned.
Packit 7cfc04
.PP
Packit 7cfc04
If
Packit 7cfc04
.I x
Packit 7cfc04
is positive infinity or negative infinity,
Packit 7cfc04
positive infinity is returned.
Packit 7cfc04
.PP
Packit 7cfc04
If
Packit 7cfc04
.I x
Packit 7cfc04
is a nonpositive integer,
Packit 7cfc04
a pole error occurs,
Packit 7cfc04
and the functions return
Packit 7cfc04
.RB + HUGE_VAL ,
Packit 7cfc04
.RB + HUGE_VALF ,
Packit 7cfc04
or
Packit 7cfc04
.RB + HUGE_VALL ,
Packit 7cfc04
respectively.
Packit 7cfc04
.PP
Packit 7cfc04
If the result overflows,
Packit 7cfc04
a range error occurs,
Packit 7cfc04
.\" e.g., lgamma(DBL_MAX)
Packit 7cfc04
and the functions return
Packit 7cfc04
.BR HUGE_VAL ,
Packit 7cfc04
.BR HUGE_VALF ,
Packit 7cfc04
or
Packit 7cfc04
.BR HUGE_VALL ,
Packit 7cfc04
respectively, with the correct mathematical sign.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
See
Packit 7cfc04
.BR math_error (7)
Packit 7cfc04
for information on how to determine whether an error has occurred
Packit 7cfc04
when calling these functions.
Packit 7cfc04
.PP
Packit 7cfc04
The following errors can occur:
Packit 7cfc04
.TP
Packit 7cfc04
Pole error: \fIx\fP is a nonpositive integer
Packit 7cfc04
.I errno
Packit 7cfc04
is set to
Packit 7cfc04
.BR ERANGE
Packit 7cfc04
(but see BUGS).
Packit 7cfc04
A divide-by-zero floating-point exception
Packit 7cfc04
.RB ( FE_DIVBYZERO )
Packit 7cfc04
is raised.
Packit 7cfc04
.TP
Packit 7cfc04
Range error: result overflow
Packit 7cfc04
.I errno
Packit 7cfc04
is set to
Packit 7cfc04
.BR ERANGE .
Packit 7cfc04
An overflow floating-point exception
Packit 7cfc04
.RB ( FE_OVERFLOW )
Packit 7cfc04
is raised.
Packit 7cfc04
.\" glibc (as at 2.8) also supports an inexact
Packit 7cfc04
.\" exception for various cases.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
The
Packit 7cfc04
.BR lgamma ()
Packit 7cfc04
functions are specified in C99, POSIX.1-2001, and POSIX.1-2008.
Packit 7cfc04
.I signgam
Packit 7cfc04
is specified in POSIX.1-2001 and POSIX.1-2008, but not in C99.
Packit 7cfc04
The
Packit 7cfc04
.BR lgamma_r ()
Packit 7cfc04
functions are nonstandard, but present on several other systems.
Packit 7cfc04
.SH BUGS
Packit 7cfc04
In glibc 2.9 and earlier,
Packit 7cfc04
.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6777
Packit 7cfc04
when a pole error occurs,
Packit 7cfc04
.I errno
Packit 7cfc04
is set to
Packit 7cfc04
.BR EDOM ;
Packit 7cfc04
instead of the POSIX-mandated
Packit 7cfc04
.BR ERANGE .
Packit 7cfc04
Since version 2.10, glibc does the right thing.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR tgamma (3)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.