'\" te .\" Copyright (c) 2001, the Institute of Electrical .\" and Electronics Engineers, Inc. and The Open Group. All Rights Reserved. .\" Copyright (c) 1992, X/Open Company Limited. .\" All Rights Reserved. .\" Copyright (c) 1983 Regents of the University .\" of California. All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" Portions Copyright (c) 2006, Sun Microsystems, .\" Inc. All Rights Reserved. .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at .\" http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html. .\" This notice shall appear on any product containing this material. .TH LGAMMA 3M "Jul 12, 2006" "SunOS 5.11" "Mathematical Library Functions" .SH NAME lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, gamma, gammaf, gammal, gamma_r, gammaf_r, gammal_r \- log gamma function .SH SYNOPSIS .LP .nf c99 [ \fIflag\fR... ] \fIfile\fR... \fB-lm\fR [ \fIlibrary\fR... ] #include extern int signgam; \fBdouble\fR \fBlgamma\fR(\fBdouble\fR \fIx\fR); .fi .LP .nf \fBfloat\fR \fBlgammaf\fR(\fBfloat\fR \fIx\fR); .fi .LP .nf \fBlong double\fR \fBlgammal\fR(\fBlong double\fR \fIx\fR); .fi .LP .nf \fBdouble\fR \fBgamma\fR(\fBdouble\fR \fIx\fR); .fi .LP .nf \fBfloat\fR \fBgammaf\fR(\fBfloat\fR \fIx\fR); .fi .LP .nf \fBlong double\fR \fBgammal\fR(\fBlong double\fR \fIx\fR); .fi .LP .nf \fBdouble\fR \fBlgamma_r\fR(\fBdouble\fR \fIx\fR, \fBint *\fR\fIsigngamp\fR); .fi .LP .nf \fBfloat\fR \fBlgammaf_r\fR(\fBfloat\fR \fIx\fR, \fBint *\fR\fIsigngamp\fR); .fi .LP .nf \fBlong double\fR \fBlgammal_r\fR(\fBlong double\fR \fIx\fR, \fBint *\fR\fIsigngamp\fR); .fi .LP .nf \fBdouble\fR \fBgamma_r\fR(\fBdouble\fR \fIx\fR, \fBint *\fR\fIsigngamp\fR); .fi .LP .nf \fBfloat\fR \fBgammaf_r\fR(\fBfloat\fR \fIx\fR, \fBint *\fR\fIsigngamp\fR); .fi .LP .nf \fBlong double\fR \fBgammal_r\fR(\fBlong double\fR \fIx\fR, \fBint *\fR\fIsigngamp\fR); .fi .SH DESCRIPTION .sp .LP These functions return .sp ln||~(x)| .sp .LP where .sp |~(x) = integral from 0 to +Infinity of pow(t,x-1)*exp(-t) dt .sp .LP for x > 0 and .sp |~(x) = n/(|~(1-x)sin(nx)) .sp .LP for x < 1. .sp .LP These functions use the external integer \fBsigngam\fR to return the sign of \fB|~(x)\fR while \fBlgamma_r()\fR and \fBgamma_r()\fR use the user-allocated space addressed by \fBsigngamp\fR. .SH RETURN VALUES .sp .LP Upon successful completion, these functions return the logarithmic gamma of \fIx\fR. .sp .LP If \fIx\fR is a non-positive integer, a pole error occurs and these functions return +\fBHUGE_VAL\fR, +\fBHUGE_VALF\fR, and +\fBHUGE_VALL\fR, respectively. .sp .LP If \fIx\fR is NaN, a NaN is returned. .sp .LP If \fIx\fR is 1 or 2, +0 shall be returned. .sp .LP If \fIx\fR is \(+-Inf, +Inf is returned. .SH ERRORS .sp .LP These functions will fail if: .sp .ne 2 .mk .na \fBPole Error\fR .ad .RS 14n .rt The \fIx\fR argument is a negative integer or 0. .sp If the integer expression (\fBmath_errhandling\fR & \fBMATH_ERREXCEPT\fR) is non-zero, then the divide-by-zero floating-point exception is raised. .RE .SH USAGE .sp .LP An application wanting to check for exceptions should call \fBfeclearexcept\fR(\fBFE_ALL_EXCEPT\fR) before calling these functions. On return, if \fBfetestexcept\fR(\fBFE_INVALID\fR | \fBFE_DIVBYZERO\fR | \fBFE_OVERFLOW\fR | \fBFE_UNDERFLOW\fR) is non-zero, an exception has been raised. An application should either examine the return value or check the floating point exception flags to detect exceptions. .sp .LP In the case of \fBlgamma()\fR, do not use the expression \fBsigngam*exp(lgamma(x))\fR to compute .sp `g := |~(x)' .sp .LP Instead compute \fBlgamma()\fR first: .sp .LP \fBlg = lgamma(x); g = signgam*exp(lg);\fR .sp .LP only after \fBlgamma()\fR has returned can \fBsigngam\fR be correct. Note that \fB|~(x)\fR must overflow when \fIx\fR is large enough, underflow when \(mi\fIx\fR is large enough, and generate a division by 0 exception at the singularities \fIx\fR a nonpositive integer. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab( ) box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability See below. _ MT-Level See below. .TE .sp .LP The \fBlgamma()\fR, \fBlgammaf()\fR, \fBlgammal()\fR, and \fBgamma()\fR functions are Standard. The \fBlgamma_r()\fR, \fBlgammaf_r()\fR, \fBlgammal_r()\fR, \fBgamma_r()\fR, \fBgammaf_r()\fR, and \fBgammal_r()\fR, functions are Stable. .sp .LP The \fBlgamma()\fR, \fBlgammaf()\fR, \fBlgammal()\fR, \fBgamma()\fR, \fBgammaf()\fR, and \fBgammal()\fR functions are Unsafe in multithreaded applications. The \fBlgamma_r()\fR, \fBlgammaf_r()\fR, \fBlgammal_r()\fR, \fBgamma_r()\fR, \fBgammaf_r()\fR, and \fBgammal_r()\fR functions are MT-Safe and should be used instead. .SH SEE ALSO .sp .LP \fBexp\fR(3M), \fBfeclearexcept\fR(3M), \fBfetestexcept\fR(3M), \fBisnan\fR(3M), \fBmath.h\fR(3HEAD), \fBattributes\fR(5), \fBstandards\fR(5) .SH NOTES .sp .LP When compiling multithreaded applications, the \fB_REENTRANT\fR flag must be defined on the compile line. This flag should only be used in multithreaded applications.