gamma_r
Compute the natural logarithm of the absolute gamma value of x, with the sign of the gamma value also returned. The input parameter is a real number.
Interface Definition
C interface:
double gamma_r(double x, int *signgam);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
For gamma_r, x is of double-precision floating-point type. |
Floating-point value of the input data. |
Input |
signgam |
In gamma_r, signgam is an integer pointer. |
Symbol for storing the gamma value of x. |
Output |
Return Value
- The natural logarithm of the absolute gamma value of x and the sign of the gamma value are returned.
- If the input is NaN, the output is NaN and the sign is 1.
- If the input is +∞, the output is +∞ and the sign is 1.
- If the input is –∞, the output is +∞ and the sign is 1.
- If the input is +0, the output is +∞ and the sign is 1.
- If the input is –0, the output is +∞ and the sign is –1.
Dependency
C: "km.h"
Example
C interface:
// print result
int sign=0;
double res=0.0;
res=gamma_r(0.0, &sign);
printf("gamma_r(0.0, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(-0.0, &sign);
printf("gamma_r(-0.0, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(0.25, &sign);
printf("gamma_r(0.25, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(-0.25, &sign);
printf("gamma_r(-0.25, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(0.5, &sign);
printf("gamma_r(0.5, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(-0.5, &sign);
printf("gamma_r(-0.5, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(1.0, &sign);
printf("gamma_r(1.0, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(-1.0, &sign);
printf("gamma_r(-1.0, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(2.0, &sign);
printf("gamma_r(2.0, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(-2.0, &sign);
printf("gamma_r(-2.0, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(INFINITY, &sign);
printf("gamma_r(INFINITY, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(-INFINITY, &sign);
printf("gamma_r(-INFINITY, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(NAN, &sign);
printf("gamma_r(NAN, &sign) = %.15f, sign = %d\n", res, sign);
res=gamma_r(-NAN, &sign);
printf("gamma_r(-NAN, &sign) = %.15f, sign = %d\n", res, sign);
/*
* gamma_r(0.0, &sign) = inf, sign = 1
* gamma_r(-0.0, &sign) = inf, sign = -1
* gamma_r(0.25, &sign) = 1.288022524698077, sign = 1
* gamma_r(-0.25, &sign) = 1.589575312551186, sign = -1
* gamma_r(0.5, &sign) = 0.572364942924700, sign = 1
* gamma_r(-0.5, &sign) = 1.265512123484645, sign = -1
* gamma_r(1.0, &sign) = 0.000000000000000, sign = 1
* gamma_r(-1.0, &sign) = inf, sign = 1
* gamma_r(2.0, &sign) = 0.000000000000000, sign = 1
* gamma_r(-2.0, &sign) = inf, sign = 1
* gamma_r(INFINITY, &sign) = inf, sign = 1
* gamma_r(-INFINITY, &sign) = inf, sign = 1
* gamma_r(NAN, &sign) = nan, sign = 1
* gamma_r(-NAN, &sign) = -nan, sign = 1
*
* */
Parent topic: Function Syntax