.\" 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" .SH NAME lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, signgam \- log gamma function .SH SYNOPSIS .nf .B #include .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 ); .sp .BI "extern int " signgam ; .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 .SH DESCRIPTION For the definition of the Gamma function, see .BR tgamma (3). .PP The .BR lgamma () function returns the natural logarithm of the absolute value of the Gamma function. The sign of the Gamma function is returned in the external integer \fIsigngam\fP declared in .IR . 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 .IR signp . .PP For non-positive integer values of \fIx\fP, .BR lgamma () returns .BR HUGE_VAL , sets \fIerrno\fP to .B ERANGE and raises the zero divide exception. (Similarly, .BR lgammaf () returns .B HUGE_VALF and .BR lgammal () returns .BR HUGE_VALL .) .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 .I errno is non-zero or .I fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred. .LP A range error occurs if .I x is too large. A pole error occurs if .I x is a negative integer or zero. .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 "SEE ALSO" .BR tgamma (3)