Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lgamma(3M) — HP-UX ANSI C A.09.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exp(3M)

isinf(3M)

isnan(3M)

matherr(3M)

values(5)

gamma(3M)

NAME

gamma(), lgamma(), signgam() − log gamma function

SYNOPSIS

#include <math.h>

double gamma(double x);

double lgamma(double x);

extern int signgam;

DESCRIPTION

gamma() and lgamma() return ln(|Γ(x)|) , where Γ(x) is defined as

∞∫0e−ttx−1dt. 

The sign of Γ(x) is returned in the external integer signgam.  The argument x must not be a non-positive integer.  (gamma() is defined over the reals excluding the non-positive integers). 

The following C program fragment can be used to calculate Γ:

if ((y = gamma(x)) > LN_MAXDOUBLE)
        error();
y = signgam * exp(y);

where if y is greater than LN_MAXDOUBLE, as defined in the <values.h> header file, exp() returns a range error (see exp(3M)).

ERRORS

/lib/libm.a

For non-positive integer arguments, gamma() and lgamma() return HUGE_VAL and set errno to EDOM.  A message indicating SING error is printed on the standard error output. 

If the correct value would overflow, gamma() and lgamma() return HUGE_VAL and set errno to ERANGE. 

gamma() and lgamma() return NaN and set errno to EDOM when x is NaN, or return +INFINITY and set errno to EDOM when x is ±INFINITY.  A message indicating DOMAIN error is printed on the standard error output. 

These error-handling procedures can be changed by using the matherr() function (see matherr(3M)).

/lib/libM.a

No error messages are printed on the standard error output. 

For non-positive integer arguments gamma() and lgamma() return HUGE_VAL and set errno to EDOM.  A message indicating SING error is printed on the standard error output. 

If the correct value would overflow, gamma() and lgamma() return HUGE_VAL and set errno to ERANGE. 

gamma() and lgamma() return NaN and set errno to EDOM when x is NaN, or return +INFINITY and set errno to EDOM when x is ±INFINITY. 

These error-handling procedures can be changed by using the _matherr() function (see matherr(3M)). Note that _matherr() is provided in order to assist in migrating programs from libm.a to libM.a and is not a part of XPG3, ANSI C, or POSIX. 

SEE ALSO

exp(3M), isinf(3M), isnan(3M), matherr(3M), values(5). 

STANDARDS CONFORMANCE

gamma() in libm.a: AES, SVID2, XPG2, XPG3
gamma() in libM.a: AES, XPG3, XPG4

lgamma() in libm.a: AES, XPG3
lgamma() in libM.a: AES, XPG3, XPG4

signgam in libm.a: AES, SVID2, XPG2, XPG3
signgam in libM.a: AES, XPG3, XPG4

Hewlett-Packard Company  —  HP-UX Release 9.0: August 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026