Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > L

lgamma(3M)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

lgamma(), lgammaf(), lgammal(), lgammaw(), lgammaq(), lgamma_r(), lgammaf_r(), lgammal_r(), lgammaw_r(), lgammaq_r(), gamma(), gammaf(), gammal(), gammaw(), gammaq(), signgam — log gamma functions

SYNOPSIS

#include <math.h>

double lgamma(double x);

double lgamma_r(double x, int *sign);

double gamma(double x);

extern int signgam;

HP Integrity Server Only

float lgammaf(float x);

long double lgammal(long double x);

extended lgammaw(extended x);

quad lgammaq(quad x);

float lgammaf_r(float x, int *sign);

long double lgammal_r(long double x, int *sign);

extended lgammaw_r(extended x, int *sign);

quad lgammaq_r(quad x, int *sign);

float gammaf(float x);

long double gammal(long double x);

extended gammaw(extended x);

quad gammaq(quad x);

DESCRIPTION

lgamma() and gamma() return ln(|Γ(x)|) , where Γ(x) is defined as the integral, as t goes from zero to infinity, of exp(-t) times t to the power (x-1).

The sign of Γ(x) is returned in the external integer signgam.

The tgamma() function, available on Integrity servers, can be used to calculate Γ(x). Or, the following C program fragment can be used to calculate Γ(x):

if ((y = lgamma(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).)

The log gamma function lgamma() is not reentrant because it uses the global variable signgam. The function lgamma_r() is a reentrant version of lgamma() that can be used in multi-threaded applications. The function lgamma_r() stores the sign of Γ(x) in the object pointed to by the second argument sign. The value pointed to by sign is +1 if Γ(x) is positive, -1 if it is negative.

The gamma() function is functionally equivalent to lgamma().

lgammaf(), gammaf(), and lgammaf_r() are float versions of lgamma(), gamma(), and lgamma_r respectively; they take a float (first) argument and return a float result.

lgammal(), gammal(), and lgammal_r() are long double versions of lgamma(), gamma(), and lgamma_r respectively; they take a long double (first) argument and return a long double result.

lgammaw(), gammaw(), and lgammaw_r() are extended versions of lgamma(), gamma(), and lgamma_r() respectively; they take an extended (first) argument and return an extended result.

lgammaq(), gammaq(), and lgammaq_r are equivalent to lgammal(), gammal(), and lgammal_r() respectively on HP-UX systems.

USAGE

To use these functions, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options.

To use (for Integrity servers) lgammaw(), lgammaw_r(), gammaw(), lgammaq(), lgammaq_r(), or gammaq(), compile also with the -fpwidetypes option.

Make sure your program includes <math.h>, and link in the math library by specifying -lm on the compiler or linker command line.

For more information, see the HP-UX floating-point guide for HP Integrity servers at the following site: http://www.hp.com/go/fp.

RETURN VALUE

lgamma(1) returns +0.

lgamma(2) returns +0.

lgamma(x) returns +Inf and raises the divide-by- zero floating-point exception for x a negative integer or zero.

lgamma(-Inf) returns +Inf.

lgamma(+Inf) returns +Inf.

If x is NaN, lgamma() and gamma() return NaN.

lgamma() returns infinity (equal to HUGE_VAL) in lieu of a value whose magnitude is too large, and raises the overflow and inexact exceptions.

When it raises no other exception, whether lgamma() raises the inexact exception is unspecified.

WARNINGS

lgamma() and gamma() are unsafe in multi-thread applications. lgamma_r() is MT-Safe and should be used instead.

STANDARDS CONFORMANCE

lgamma() : SVID3, XPG4.2, ISO/IEC C99 (including Annex F, "IEC 60559 floating-point arithmetic")

gamma() : SVID3, XPG4.2

lgammaf(), lgammal() : ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.