2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
|
|
|
|
.\" Distributed under GPL
|
|
|
|
.\" based on glibc infopages
|
2008-08-01 05:26:26 +00:00
|
|
|
.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
|
|
|
|
.\" <mtk.manpages@gmail.com>
|
2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
2010-09-11 14:22:04 +00:00
|
|
|
.TH LGAMMA 3 2010-09-11 "" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
2007-07-08 12:11:40 +00:00
|
|
|
lgamma, lgammaf, lgammal, lgamma_r, lgammaf_r, lgammal_r, signgam \-
|
|
|
|
log gamma function
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
|
|
|
.B #include <math.h>
|
|
|
|
.sp
|
|
|
|
.BI "double lgamma(double " x );
|
|
|
|
.br
|
|
|
|
.BI "float lgammaf(float " x );
|
|
|
|
.br
|
|
|
|
.BI "long double lgammal(long double " x );
|
|
|
|
.sp
|
|
|
|
.BI "double lgamma_r(double " x ", int *" signp );
|
|
|
|
.br
|
|
|
|
.BI "float lgammaf_r(float " x ", int *" signp );
|
|
|
|
.br
|
|
|
|
.BI "long double lgammal_r(long double " x ", int *" signp );
|
2007-07-11 18:37:22 +00:00
|
|
|
.sp
|
2007-07-08 12:11:40 +00:00
|
|
|
.BI "extern int " signgam ;
|
2004-11-03 13:51:07 +00:00
|
|
|
.fi
|
|
|
|
.sp
|
2007-07-08 12:11:40 +00:00
|
|
|
Link with \fI\-lm\fP.
|
|
|
|
.sp
|
|
|
|
.in -4n
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
|
|
.BR feature_test_macros (7)):
|
|
|
|
.in
|
|
|
|
.sp
|
|
|
|
.ad l
|
2008-08-01 05:26:26 +00:00
|
|
|
.BR lgamma ():
|
2010-09-19 04:42:04 +00:00
|
|
|
.RS 4
|
2010-09-19 04:43:01 +00:00
|
|
|
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE ||
|
|
|
|
_POSIX_C_SOURCE\ >=\ 200112L;
|
2010-09-19 04:42:04 +00:00
|
|
|
.br
|
|
|
|
or
|
2008-08-01 05:26:26 +00:00
|
|
|
.I cc\ -std=c99
|
2010-09-19 04:42:04 +00:00
|
|
|
.RE
|
2008-08-01 05:26:26 +00:00
|
|
|
.br
|
2007-07-08 12:11:40 +00:00
|
|
|
.BR lgammaf (),
|
|
|
|
.BR lgammal ():
|
2010-09-19 04:42:04 +00:00
|
|
|
.RS 4
|
2010-09-19 04:43:01 +00:00
|
|
|
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
|
|
|
|
_POSIX_C_SOURCE\ >=\ 200112L;
|
2010-09-19 04:42:04 +00:00
|
|
|
.br
|
|
|
|
or
|
2007-07-08 12:11:40 +00:00
|
|
|
.I cc\ -std=c99
|
2010-09-19 05:36:47 +00:00
|
|
|
.RE
|
2007-07-08 12:11:40 +00:00
|
|
|
.BR lgamma_r (),
|
|
|
|
.BR lgammaf_r (),
|
|
|
|
.BR lgammal_r ():
|
2010-09-19 05:36:47 +00:00
|
|
|
.RS 4
|
2007-07-08 12:11:40 +00:00
|
|
|
_BSD_SOURCE || _SVID_SOURCE
|
2010-09-19 05:36:47 +00:00
|
|
|
.RE
|
2007-07-08 12:11:40 +00:00
|
|
|
.IR signgam :
|
2010-09-19 05:36:47 +00:00
|
|
|
.RS 4
|
2007-07-08 12:11:40 +00:00
|
|
|
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE
|
2010-09-19 05:36:47 +00:00
|
|
|
.RE
|
2007-07-08 12:11:40 +00:00
|
|
|
.ad b
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
For the definition of the Gamma function, see
|
|
|
|
.BR tgamma (3).
|
|
|
|
.PP
|
2007-05-12 09:06:04 +00:00
|
|
|
The
|
|
|
|
.BR lgamma ()
|
|
|
|
function returns the natural logarithm of
|
2004-11-03 13:51:07 +00:00
|
|
|
the absolute value of the Gamma function.
|
|
|
|
The sign of the Gamma function is returned in the
|
|
|
|
external integer \fIsigngam\fP declared in
|
|
|
|
.IR <math.h> .
|
|
|
|
It is 1 when the Gamma function is positive or zero, \-1
|
|
|
|
when it is negative.
|
|
|
|
.PP
|
|
|
|
Since using a constant location
|
|
|
|
.I signgam
|
2007-05-12 09:06:04 +00:00
|
|
|
is not thread-safe, the functions
|
|
|
|
.BR lgamma_r ()
|
|
|
|
etc. have
|
2008-08-01 05:26:26 +00:00
|
|
|
been introduced; they return the sign via the argument
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR signp .
|
2008-08-01 05:26:26 +00:00
|
|
|
.SH RETURN VALUE
|
|
|
|
On success, these functions return the natural logarithm of Gamma(x).
|
|
|
|
|
|
|
|
If
|
|
|
|
.I x
|
|
|
|
is a NaN, a NaN is returned.
|
|
|
|
|
|
|
|
If
|
|
|
|
.I x
|
|
|
|
is 1 or 2, +0 is returned.
|
|
|
|
|
|
|
|
If
|
|
|
|
.I x
|
|
|
|
is positive infinity or negative infinity,
|
|
|
|
positive infinity is returned.
|
|
|
|
|
|
|
|
If
|
|
|
|
.I x
|
2010-01-16 16:47:13 +00:00
|
|
|
is a nonpositive integer,
|
2008-08-04 16:00:58 +00:00
|
|
|
a pole error occurs,
|
2008-08-01 05:26:26 +00:00
|
|
|
and the functions return
|
|
|
|
.RB + HUGE_VAL ,
|
|
|
|
.RB + HUGE_VALF ,
|
|
|
|
or
|
|
|
|
.RB + HUGE_VALL ,
|
|
|
|
respectively.
|
|
|
|
|
|
|
|
If the result overflows,
|
2008-08-04 16:00:58 +00:00
|
|
|
a range error occurs,
|
2008-08-01 05:26:26 +00:00
|
|
|
.\" e.g., lgamma(DBL_MAX)
|
|
|
|
and the functions return
|
2007-06-22 19:42:52 +00:00
|
|
|
.BR HUGE_VAL ,
|
2008-08-01 05:26:26 +00:00
|
|
|
.BR HUGE_VALF ,
|
|
|
|
or
|
|
|
|
.BR HUGE_VALL ,
|
|
|
|
respectively, with the correct mathematical sign.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH ERRORS
|
2008-08-01 05:26:26 +00:00
|
|
|
See
|
|
|
|
.BR math_error (7)
|
|
|
|
for information on how to determine whether an error has occurred
|
|
|
|
when calling these functions.
|
|
|
|
.PP
|
|
|
|
The following errors can occur:
|
|
|
|
.TP
|
2010-01-16 16:47:13 +00:00
|
|
|
Pole error: \fIx\fP is a nonpositive integer
|
2004-11-03 13:51:07 +00:00
|
|
|
.I errno
|
2008-08-01 05:26:26 +00:00
|
|
|
is set to
|
2008-08-05 10:33:06 +00:00
|
|
|
.BR ERANGE
|
2008-08-01 05:26:26 +00:00
|
|
|
(but see BUGS).
|
|
|
|
A divide-by-zero floating-point exception
|
|
|
|
.RB ( FE_DIVBYZERO )
|
|
|
|
is raised.
|
|
|
|
.TP
|
|
|
|
Range error: result overflow
|
2004-11-03 13:51:07 +00:00
|
|
|
.I errno
|
2008-08-01 05:26:26 +00:00
|
|
|
is set to
|
|
|
|
.BR ERANGE .
|
|
|
|
An overflow floating-point exception
|
|
|
|
.RB ( FE_OVERFLOW )
|
|
|
|
is raised.
|
|
|
|
.\" glibc (as at 2.8) also supports an inexact
|
|
|
|
.\" exception for various cases.
|
2008-08-05 10:27:16 +00:00
|
|
|
.SH "CONFORMING TO"
|
|
|
|
The
|
|
|
|
.BR lgamma ()
|
|
|
|
functions are specified in C99 and POSIX.1-2001.
|
|
|
|
.I signgam
|
|
|
|
is specified in POSIX.1-2001, but not in C99.
|
|
|
|
The
|
|
|
|
.BR lgamma_r ()
|
accept.2, execve.2, futimesat.2, getresuid.2, getrlimit.2, madvise.2, mq_getsetattr.2, msgctl.2, nice.2, open.2, poll.2, setresuid.2, shmctl.2, sigaction.2, times.2, utimensat.2, __setfpucw.3, atoi.3, endian.3, err.3, euidaccess.3, fenv.3, fopencookie.3, fpurge.3, getgrouplist.3, getutmp.3, j0.3, lgamma.3, netlink.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_cleanup_push_defer_np.3, pthread_getattr_np.3, pthread_kill_other_threads_np.3, pthread_setaffinity_np.3, pthread_tryjoin_np.3, pthread_yield.3, random_r.3, readdir.3, rtnetlink.3, scanf.3, setenv.3, significand.3, sigsetops.3, strerror.3, strstr.3, sysv_signal.3, termios.3, timegm.3, unlocked_stdio.3, y0.3, locale.5, bootparam.7, feature_test_macros.7, ip.7, locale.7, pthreads.7, rtld-audit.7, nscd.8: Global fix: s/non-standard/nonstandard/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:37:52 +00:00
|
|
|
functions are nonstandard, but present on several other systems.
|
2008-08-01 05:26:26 +00:00
|
|
|
.SH BUGS
|
2010-09-11 14:22:04 +00:00
|
|
|
In glibc 2.9 and earlier,
|
|
|
|
.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6777
|
|
|
|
when a pole error occurs,
|
2008-08-01 05:26:26 +00:00
|
|
|
.I errno
|
|
|
|
is set to
|
|
|
|
.BR EDOM ;
|
2010-09-11 14:22:04 +00:00
|
|
|
instead of the POSIX-mandated
|
2008-08-01 05:26:26 +00:00
|
|
|
.BR ERANGE .
|
2010-09-11 14:22:04 +00:00
|
|
|
Since version 2.10, glibc does the right thing.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR tgamma (3)
|