man-pages/man3/lgamma.3

116 lines
2.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
.\"
.TH LGAMMA 3 2007-07-26 "" "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 (),
.BR lgammaf (),
.BR lgammal ():
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _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 this sign via the argument
2004-11-03 13:51:07 +00:00
.IR signp .
.PP
For non-positive integer values of \fIx\fP,
.BR lgamma ()
2007-06-22 19:42:52 +00:00
returns
.BR HUGE_VAL ,
2007-06-22 18:09:13 +00:00
sets \fIerrno\fP to
.B ERANGE
and raises the zero divide exception.
(Similarly,
.BR lgammaf ()
2007-06-22 19:42:52 +00:00
returns
.B HUGE_VALF
and
.BR lgammal ()
returns
2007-06-22 19:42:52 +00:00
.BR HUGE_VALL .)
2004-11-03 13:51:07 +00:00
.SH ERRORS
In order to check for errors, set
.I errno
to zero and call
.I feclearexcept(FE_ALL_EXCEPT)
before calling these functions.
On return, if
2004-11-03 13:51:07 +00:00
.I errno
2008-03-19 13:16:39 +00:00
is non-zero or
2004-11-03 13:51:07 +00:00
.I fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)
2008-03-19 13:16:39 +00:00
is non-zero, an error has occurred.
2004-11-03 13:51:07 +00:00
.LP
2007-07-09 20:29:37 +00:00
A range error occurs if
.I x
is too large.
A pole error occurs if
.I x
is a negative integer or zero.
2004-11-03 13:51:07 +00:00
.SH "CONFORMING TO"
2007-07-10 05:34:35 +00:00
The
.BR lgamma ()
2007-07-10 05:38:52 +00:00
functions are specified in C99 and POSIX.1-2001.
2007-07-10 05:34:35 +00:00
.I signgam
is specified in POSIX.1-2001, but not in C99.
The
.BR lgamma_r ()
2007-07-10 05:38:52 +00:00
functions are non-standard, but present on several other systems.
2004-11-03 13:51:07 +00:00
.SH "SEE ALSO"
.BR tgamma (3)