1LGAMMA(3)                  Linux Programmer's Manual                 LGAMMA(3)
2
3
4

NAME

6       lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, signgam - log
7       gamma function
8

SYNOPSIS

10       #include <math.h>
11
12       double lgamma(double x);
13       float lgammaf(float x);
14       long double lgammal(long double x);
15
16       double lgamma_r(double x, int *signp);
17       float lgammaf_r(float x, int *signp);
18       long double lgammal_r(long double x, int *signp);
19
20       extern int signgam;
21
22       Link with -lm.
23
24   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
25
26       lgamma():
27           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE
28               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
29               || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
30       lgammaf(), lgammal():
31           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
32               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
33               || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
34       lgamma_r(), lgammaf_r(), lgammal_r():
35           /* Since glibc 2.19: */ _DEFAULT_SOURCE
36               || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
37       signgam:
38           _XOPEN_SOURCE
39               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
40               || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
41

DESCRIPTION

43       For the definition of the Gamma function, see tgamma(3).
44
45       The lgamma(), lgammaf(), and lgammal()  functions  return  the  natural
46       logarithm of the absolute value of the Gamma function.  The sign of the
47       Gamma function is returned in the external integer signgam declared  in
48       <math.h>.  It is 1 when the Gamma function is positive or zero, -1 when
49       it is negative.
50
51       Since using a constant location signgam is not thread-safe,  the  func‐
52       tions  lgamma_r(),  lgammaf_r(),  and lgammal_r() have been introduced;
53       they return the sign via the argument signp.
54

RETURN VALUE

56       On success, these functions return the natural logarithm of Gamma(x).
57
58       If x is a NaN, a NaN is returned.
59
60       If x is 1 or 2, +0 is returned.
61
62       If x is positive infinity or negative infinity,  positive  infinity  is
63       returned.
64
65       If  x  is a nonpositive integer, a pole error occurs, and the functions
66       return +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL, respectively.
67
68       If the result overflows, a range error occurs, and the functions return
69       HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the correct math‐
70       ematical sign.
71

ERRORS

73       See math_error(7) for information on how to determine whether an  error
74       has occurred when calling these functions.
75
76       The following errors can occur:
77
78       Pole error: x is a nonpositive integer
79              errno  is set to ERANGE (but see BUGS).  A divide-by-zero float‐
80              ing-point exception (FE_DIVBYZERO) is raised.
81
82       Range error: result overflow
83              errno is set to ERANGE.  An  overflow  floating-point  exception
84              (FE_OVERFLOW) is raised.
85

CONFORMING TO

87       The   lgamma()  functions  are  specified  in  C99,  POSIX.1-2001,  and
88       POSIX.1-2008.  signgam is specified in POSIX.1-2001  and  POSIX.1-2008,
89       but  not in C99.  The lgamma_r() functions are nonstandard, but present
90       on several other systems.
91

BUGS

93       In glibc 2.9 and earlier, when a pole error occurs,  errno  is  set  to
94       EDOM;  instead of the POSIX-mandated ERANGE.  Since version 2.10, glibc
95       does the right thing.
96

SEE ALSO

98       tgamma(3)
99

COLOPHON

101       This page is part of release 5.07 of the Linux  man-pages  project.   A
102       description  of  the project, information about reporting bugs, and the
103       latest    version    of    this    page,    can     be     found     at
104       https://www.kernel.org/doc/man-pages/.
105
106
107
108                                  2017-09-15                         LGAMMA(3)
Impressum