Mathematical Library Functions lgamma(3M)
NAME
lgamma, lgammaf, lgammal, lgammar, lgammafr, lgammalr,
gamma, gammaf, gammal, gammar, gammafr, gammalr - log
gamma function
SYNOPSIS
c99 [ flag... ] file... -lm [ library... ]
#include
extern int signgam;
double lgamma(double x);
float lgammaf(float x);
long double lgammal(long double x);
double gamma(double x);
float gammaf(float x);
long double gammal(long double x);
double lgammar(double x, int *signgamp);
float lgammafr(float x, int *signgamp);
long double lgammalr(long double x, int *signgamp);
double gammar(double x, int *signgamp);
float gammafr(float x, int *signgamp);
long double gammalr(long double x, int *signgamp);
DESCRIPTION
These functions return
ln~(x)
SunOS 5.11 Last change: 12 Jul 2006 1
Mathematical Library Functions lgamma(3M)
where
~(x) = integral from 0 to ]Infinity of pow(t,x-1)*exp(-t)
dt
for x > 0 and
~(x) = n/(~(1-x)sin(nx))
for x < 1.
These functions use the external integer signgam to return
the sign of ~(x) while lgammar() and gammar() use the
user-allocated space addressed by signgamp.
RETURN VALUES
Upon successful completion, these functions return the loga-
rithmic gamma of x.
If x is a non-positive integer, a pole error occurs and
these functions return ]HUGEVAL, ]HUGEVALF, and
]HUGEVAL, respectively.
If x is NaN, a NaN is returned.
If x is 1 or 2, ]0 shall be returned.
If x is ]Inf, ]Inf is returned.
ERORS
These functions will fail if:
Pole Error The x argument is a negative integer or 0.
If the integer expression (matherrhandling &
MATHEREXCEPT) is non-zero, then the divide-
by-zero floating-point exception is raised.
USAGE
An application wanting to check for exceptions should call
feclearexcept(FEALEXCEPT) before calling these functions.
On return, if fetestexcept(FEINVALID FEDIVBYZERO
FEOVERFLOW FEUNDERFLOW) is non-zero, an exception has
been raised. An application should either examine the return
SunOS 5.11 Last change: 12 Jul 2006 2
Mathematical Library Functions lgamma(3M)
value or check the floating point exception flags to detect
exceptions.
In the case of lgamma(), do not use the expression
signgam*exp(lgamma(x)) to compute
`g := ~(x)'
Instead compute lgamma() first:
lg = lgamma(x); g = signgam*exp(lg);
only after lgamma() has returned can signgam be correct.
Note that ~(x) must overflow when x is large enough, under-
flow when -x is large enough, and generate a division by 0
exception at the singularities x a nonpositive integer.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability See below.
MT-Level See below.
The lgamma(), lgammaf(), lgammal(), and gamma() functions
are Standard. The lgammar(), lgammafr(), lgammalr(),
gammar(), gammafr(), and gammalr(), functions are Stable.
The lgamma(), lgammaf(), lgammal(), gamma(), gammaf(), and
gammal() functions are Unsafe in multithreaded applications.
The lgammar(), lgammafr(), lgammalr(), gammar(),
gammafr(), and gammalr() functions are MT-Safe and should
be used instead.
SEE ALSO
exp(3M), feclearexcept(3M), fetestexcept(3M), isnan(3M),
math.h(3HEAD), attributes(5), standards(5)
SunOS 5.11 Last change: 12 Jul 2006 3
Mathematical Library Functions lgamma(3M)
NOTES
When compiling multithreaded applications, the RENTRANT
flag must be defined on the compile line. This flag should
only be used in multithreaded applications.
SunOS 5.11 Last change: 12 Jul 2006 4
|