man-pages/man3/lgamma.3

160 lines
3.4 KiB
Groff
Raw Normal View History

2004-11-03 13:51:07 +00:00
.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
.\" Distributed under GPL
.\" based on glibc infopages
.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
.\" <mtk.manpages@gmail.com>
2004-11-03 13:51:07 +00:00
.\"
2008-08-01 05:54:27 +00:00
.TH LGAMMA 3 2008-08-05 "" "Linux Programmer's Manual"
2004-11-03 13:51:07 +00:00
.SH NAME
lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, signgam \-
log gamma function
2004-11-03 13:51:07 +00:00
.SH SYNOPSIS
.nf
.B #include <math.h>
.sp
.BI "double lgamma(double " x );
.br
.BI "float lgammaf(float " x );
.br
.BI "long double lgammal(long double " x );
.sp
.BI "double lgamma_r(double " x ", int *" signp );
.br
.BI "float lgammaf_r(float " x ", int *" signp );
.br
.BI "long double lgammal_r(long double " x ", int *" signp );
2007-07-11 18:37:22 +00:00
.sp
.BI "extern int " signgam ;
2004-11-03 13:51:07 +00:00
.fi
.sp
Link with \fI\-lm\fP.
.sp
.in -4n
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.in
.sp
.ad l
.BR lgamma ():
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE; or
.I cc\ -std=c99
.br
.BR lgammaf (),
.BR lgammal ():
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or
.I cc\ -std=c99
.br
.BR lgamma_r (),
.BR lgammaf_r (),
.BR lgammal_r ():
_BSD_SOURCE || _SVID_SOURCE
.br
.IR signgam :
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE
.ad b
2004-11-03 13:51:07 +00:00
.SH DESCRIPTION
For the definition of the Gamma function, see
.BR tgamma (3).
.PP
The
.BR lgamma ()
function returns the natural logarithm of
2004-11-03 13:51:07 +00:00
the absolute value of the Gamma function.
The sign of the Gamma function is returned in the
external integer \fIsigngam\fP declared in
.IR <math.h> .
It is 1 when the Gamma function is positive or zero, \-1
when it is negative.
.PP
Since using a constant location
.I signgam
is not thread-safe, the functions
.BR lgamma_r ()
etc. have
been introduced; they return the sign via the argument
2004-11-03 13:51:07 +00:00
.IR signp .
.SH RETURN VALUE
On success, these functions return the natural logarithm of Gamma(x).
If
.I x
is a NaN, a NaN is returned.
If
.I x
is 1 or 2, +0 is returned.
If
.I x
is positive infinity or negative infinity,
positive infinity is returned.
If
.I x
is a non-positive integer,
2008-08-04 16:00:58 +00:00
a pole error occurs,
and the functions return
.RB + HUGE_VAL ,
.RB + HUGE_VALF ,
or
.RB + HUGE_VALL ,
respectively.
If the result overflows,
2008-08-04 16:00:58 +00:00
a range error occurs,
.\" e.g., lgamma(DBL_MAX)
and the functions return
2007-06-22 19:42:52 +00:00
.BR HUGE_VAL ,
.BR HUGE_VALF ,
or
.BR HUGE_VALL ,
respectively, with the correct mathematical sign.
2004-11-03 13:51:07 +00:00
.SH ERRORS
See
.BR math_error (7)
for information on how to determine whether an error has occurred
when calling these functions.
.PP
The following errors can occur:
.TP
Pole error: \fIx\fP is a non-positive integer
2004-11-03 13:51:07 +00:00
.I errno
is set to
.\" FIXME . glibc 2.8 gives EDOM!
.BR ERANGE
(but see BUGS).
A divide-by-zero floating-point exception
.RB ( FE_DIVBYZERO )
is raised.
.TP
Range error: result overflow
2004-11-03 13:51:07 +00:00
.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.
2008-08-05 10:27:16 +00:00
.SH "CONFORMING TO"
The
.BR lgamma ()
functions are specified in C99 and POSIX.1-2001.
.I signgam
is specified in POSIX.1-2001, but not in C99.
The
.BR lgamma_r ()
functions are non-standard, but present on several other systems.
.SH BUGS
For a pole error,
.\"
.\" FIXME . this is as at glibc 2.8; check later if this bug is fixed
.\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6777
.I errno
is set to
.BR EDOM ;
POSIX.1 says it should be set to
.BR ERANGE .
2004-11-03 13:51:07 +00:00
.SH "SEE ALSO"
.BR tgamma (3)