function
<cmath> <ctgmath>
lgamma
double lgamma (double x);
float lgammaf (float x);
long double lgammal (long double x);
double lgamma (double x);
float lgamma (float x);
long double lgamma (long double x);
double lgamma (T x); // additional overloads for integral types
Compute log-gamma function
Returns the natural logarithm of the absolute value of the gamma function of x.
Header
<tgmath.h> provides a type-generic macro version of this function.
Additional overloads are provided in this header (
<cmath>
) for the
integral types: These overloads effectively cast
x to a
double
before calculations (defined for
T being any
integral type).
Parameters
- x
- Parameter for the log-gamma function.
Example
1 2 3 4 5 6 7 8 9 10 11 12
|
/* lgamma example */
#include <stdio.h> /* printf */
#include <math.h> /* lgamma */
int main ()
{
double param, result;
param = 0.5;
result = lgamma (param);
printf ("lgamma(%f) = %f\n", param, result );
return 0;
}
| |
Output:
lgamma (0.500000) = 0.572365
|
See also
- tgamma
- Compute gamma function (function
)
- erf
- Compute error function (function
)
- erfc
- Compute complementary error function (function
)