lgamma_r
计算x的伽马值绝对值的自然对数,返回伽马值的符号,输入参数为实数。
接口定义
C interface:
float lgammaf(float x);
double lgamma(double x);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
返回值
- 返回入参x的伽马值绝对值的自然对数、伽马值的符号。
- 输入nan,返回nan,符号为1。
- 输入+∞,返回+∞,符号为1。
- 输入-∞,返回+∞,符号为1。
- 输入+0,返回+∞,符号为1。
- 输入-0,返回+∞,符号为-1。
依赖
C: "km.h"
示例
C interface:
// print result int sign=0; double res=0.0; res=lgamma_r(0.0, &sign); printf("lgamma_r(0.0, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(-0.0, &sign); printf("lgamma_r(-0.0, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(0.25, &sign); printf("lgamma_r(0.25, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(-0.25, &sign); printf("lgamma_r(-0.25, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(0.5, &sign); printf("lgamma_r(0.5, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(-0.5, &sign); printf("lgamma_r(-0.5, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(1.0, &sign); printf("lgamma_r(1.0, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(-1.0, &sign); printf("lgamma_r(-1.0, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(2.0, &sign); printf("lgamma_r(2.0, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(-2.0, &sign); printf("lgamma_r(-2.0, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(INFINITY, &sign); printf("lgamma_r(INFINITY, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(-INFINITY, &sign); printf("lgamma_r(-INFINITY, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(NAN, &sign); printf("lgamma_r(NAN, &sign) = %.15f, sign = %d\n", res, sign); res=lgamma_r(-NAN, &sign); printf("lgamma_r(-NAN, &sign) = %.15f, sign = %d\n", res, sign); /* * lgamma_r(0.0, &sign) = inf, sign = 1 * lgamma_r(-0.0, &sign) = inf, sign = -1 * lgamma_r(0.25, &sign) = 1.288022524698077, sign = 1 * lgamma_r(-0.25, &sign) = 1.589575312551186, sign = -1 * lgamma_r(0.5, &sign) = 0.572364942924700, sign = 1 * lgamma_r(-0.5, &sign) = 1.265512123484645, sign = -1 * lgamma_r(1.0, &sign) = 0.000000000000000, sign = 1 * lgamma_r(-1.0, &sign) = inf, sign = 1 * lgamma_r(2.0, &sign) = 0.000000000000000, sign = 1 * lgamma_r(-2.0, &sign) = inf, sign = 1 * lgamma_r(INFINITY, &sign) = inf, sign = 1 * lgamma_r(-INFINITY, &sign) = inf, sign = 1 * lgamma_r(NAN, &sign) = nan, sign = 1 * lgamma_r(-NAN, &sign) = -nan, sign = 1 * * */
父主题: 特殊函数