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           _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE ||
28           _POSIX_C_SOURCE >= 200112L;
29           or cc -std=c99
30       lgammaf(), lgammal():
31           _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 ||
32           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
33           or cc -std=c99
34       lgamma_r(), lgammaf_r(), lgammal_r():
35           _BSD_SOURCE || _SVID_SOURCE
36       signgam:
37           _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE
38

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

CONFORMING TO

83       The lgamma() functions are specified in C99 and POSIX.1-2001.   signgam
84       is specified in POSIX.1-2001, but not in C99.  The lgamma_r() functions
85       are nonstandard, but present on several other systems.
86

BUGS

88       In glibc 2.9 and earlier, when a pole error occurs,  errno  is  set  to
89       EDOM;  instead of the POSIX-mandated ERANGE.  Since version 2.10, glibc
90       does the right thing.
91

SEE ALSO

93       tgamma(3)
94

COLOPHON

96       This page is part of release 3.53 of the Linux  man-pages  project.   A
97       description  of  the project, and information about reporting bugs, can
98       be found at http://www.kernel.org/doc/man-pages/.
99
100
101
102                                  2010-09-11                         LGAMMA(3)
Impressum