 |
|
|
NAME
| | lgamma, lgamma_r, gamma, gamma_r - log
gamma function |
SYNOPSIS
| |
cc [ flag ... ] file ... -lm [ library ... ]
#include <math.h>
extern int signgam; double lgamma(double x); |
| | double lgamma_r(double x, int *signgamp); |
| | double gamma_r(double x, int *signgamp); |
| |
The lgamma(), gamma(), lgamma_r(), and gamma_r() functions return
where
for x > 0 and
for x < 1.
The lgamma() and gamma() functions use the external integer signgam to return the sign of |~(x) while lgamma_r() and gamma_r() use the user-allocated space addressed by signgamp.
|
| |
In the case of lgamma(), do not use the expression signgam*exp(lgamma(x)) to compute
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, underflow when -x is large enough, and generate a division by 0 exception at the singularities x a nonpositive integer.
|
| |
For exceptional cases, matherr(3M) tabulates the values to be returned as dictated by various Standards.
|
| |
See attributes(5) for descriptions of the following attributes:
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
| MT-Level | See NOTES below. |
|
| |
Although lgamma_r() is not mentioned by POSIX 1003.1c, it was added to complete the functionality provided by similar thread-safe functions.
The gamma() function is currently maintained for compatibility with SVID3. See standards(5). The gamma() function and
the gamma_r() function may be removed from a future release. The lgamma() and lgamma_r() functions should be used instead.
When compiling multi-thread applications, the _REENTRANT flag must be defined on the compile line. This flag should only be used in multi-thread applications.
The lgamma() function is unsafe in multithreaded applications. The lgamma_r() function should be used instead.
|
Company Info
|
Contact
|
Copyright 2003 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
|