|
|
HP-UX Reference Volume 4 of 5 > llgamma(3M) |
|
NAMElgamma(), 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); DESCRIPTIONlgamma() 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 (x-1). The sign of Γ(x) is returned in the external integer signgam. The argument x must not be zero or a negative 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 applications. 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 standard. 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 VALUEIf 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. |
|