Index of Section 3 Manual Pages

Interix / SUAgamma_r.3Interix / SUA

gamma_r(3)                                                   gamma_r(3)

  lgamma()

  NAME

    lgamma(), gamma(), lgamma_r(), gamma_r() - log gamma function, gamma
    function, signgam variable

  SYNOPSIS

    #include 
    extern int signgam;

    double lgamma (double x)
    double gamma (double x)
    double lgamma_r (double x, int *signgamp)
    double gamma_r (double x, int *signgamp)

  DESCRIPTION

    Gamma(x) returns |¯(x), with no effect on signgam.

    Depending on the value of the variable _LIB_VERSION, lgamma(3) may be the
    same as gamma(3) (as specified by the XPG) or it may return ln||¯(x)|
    where |¯(x) = integral from 0 to +Infinity of pow(t,x-1)*exp(-t) dt for x
    > 0 and |¯(x) = n/(|¯(1-x)sin(nx)) for x < 1. See NOTES.

    The external integer signgam returns the sign of |¯(x).

    The functions gamma_r(3) and lgamma_r(3) are reentrant versions of
    gamma(3) and lgamma(3) (where lgamma_r(3) always returns the logarithm of
    the gamma function). The argument signgamp is a pointer to a user-provided
    variable which will contain the sign of the x) after the call returns.

  IDIOSYNCRASIES

    Do not use the expression signgam*exp(lgamma(x)) to compute g := |¯(x).
    Instead use a program like this (in C):

    lg = lgamma(x); g = signgam*exp(lg);

    Only after lgamma(3) has returned can signgam be correct.

    For arguments in its range, gamma(3) is preferred, as for positive
    arguments it is accurate to within one unit in the last place.
    Exponentiation of lgamma(3) will lose up to 10 significant bits.

  RETURN VALUES

    Gamma(3) and lgamma(3) return appropriate values unless an argument is out
    of range. Overflow will occur for sufficiently large positive values. For
    large non-integer negative values, gamma(3) will underflow.

  ERRORS

    The lgamma(3) function can fail for the following reasons:

    [EDOM]
        The argument x is a non-positive integer or NaN.

    [ERANGE]
        The result would have caused an underflow or overflow.

  NOTES

    The name gamma(3) was originally dedicated to the lgamma(3) function, so
    some old code may no longer be compatible. For this reason, the XPG
    specifications make gamma(3) and lgamma(3) identical. If you want
    lgamma(3) to actually return the logarithm, set the value of the global
    variable _LIB_VERSION to the value _BSD44_ (the default value is _XOPEN_).

    The variable _LIB_VERSION dictates the conformance aspects of the math
    APIs, primarily errors and boundary conditions. The code has only been
    tested for conformance with the value _XOPEN_.

    To avoid possible conflicts in behavior, set _LIB_VERSION to _BSD44_
    immediately before the call to lgamma(3) and set it back to _XOPEN_
    immediately after.

  SEE ALSO

    math(3)

  USAGE NOTES

    The following functions are thread safe: gamma, lgamma_r, gamma_r. The
    lgamma function is not thread safe.

    None of these functions are async-signal safe.


Interix / SUAHosted at SUA Community for Interix, SUA and SFUInterix / SUA