HP-UX Reference (11i v1 00/12) - 3 Library Functions A-M (vol 6)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/!!!intro.3c
________________________________________________________________
___ ___
l
lgamma(3M) lgamma(3M)
NAME
lgamma(), lgamma_r(), gamma(), signgam() - log gamma function
SYNOPSIS
#include <math.h>
double lgamma(double x);
double gamma(double x);
(TO BE WITHDRAWN)
extern int signgam;
double lgamma_r(double x, int *sign);
DESCRIPTION
lgamma() and gamma() return ln(|Γ(x)|), where Γ(x) is defined as the integral, as t goes from zero
to infinity, of exp(t) times t to the power (x1).
The sign of Γ(x) is returned in the external integer signgam. The argument x must not be zero or a nega-
tive integer. (lgamma() is defined over the reals excluding the non-positive integers.)
The following C program fragment can be used to calculate Γ(x):
if ((y = lgamma(x)) > LN_MAXDOUBLE)
error( );
y = signgam * exp(y);
where if y is greater than LN_MAXDOUBLE , as defined in the <values.h> header file,
exp() returns a
range error (see exp(3M)).
The log gamma function
lgamma() is not reentrant because it uses the global variable signgam. The
function
lgamma_r() is a reentrant version of lgamma() that can be used in multi-threaded applica-
tions. The function lgamma_r() returns the sign of Γ(x) in its parameter list, through the pointer sign.
The value pointed to by sign is +1 if Γ(x) is positive, -1 if it is negative.
The
gamma() function is functionally equivalent to lgamma(), and in the XPG4.2 standard it is marked
TO BE WITHDRAWN. A true gamma() function has been approved for inclusion in the C9X draft stan-
dard.
The ISO/ANSI C committee has approved the
lgamma() function for inclusion in the C9X draft standard.
To use these functions, compile either with the default
-Ae option or with the -Aa
and
-D_HPUX_SOURCE options. Make sure your program includes <
math.h>. Link in the math library by
specifying
-lm on the compiler or linker command line.
RETURN VALUE
If x is a non-positive integer, lgamma() and gamma() return HUGE_VAL.
If the correct value would overflow, lgamma() and gamma() return HUGE_VAL.
If the correct value after rounding would be smaller in magnitude than MINDOUBLE, lgamma() and
gamma() return zero.
If x is NaN, lgamma() and gamma() return NaN.
ERRORS
No errors are defined.
WARNINGS
lgamma() and gamma() are unsafe in multi-thread applications. lgamma_r() is MT-Safe and should
be used instead.
SEE ALSO
exp(3M), math(5), values(5).
HP-UX Release 11i: December 2000 1 Section 3485
___
___