Blame gsl/gsl_sf_gamma.h

Packit e8bc57
/* specfunc/gsl_sf_gamma.h
Packit e8bc57
 * 
Packit e8bc57
 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
Packit e8bc57
 * 
Packit e8bc57
 * This program is free software; you can redistribute it and/or modify
Packit e8bc57
 * it under the terms of the GNU General Public License as published by
Packit e8bc57
 * the Free Software Foundation; either version 2 of the License, or (at
Packit e8bc57
 * your option) any later version.
Packit e8bc57
 * 
Packit e8bc57
 * This program is distributed in the hope that it will be useful, but
Packit e8bc57
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit e8bc57
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit e8bc57
 * General Public License for more details.
Packit e8bc57
 * 
Packit e8bc57
 * You should have received a copy of the GNU General Public License
Packit e8bc57
 * along with this program; if not, write to the Free Software
Packit e8bc57
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit e8bc57
 */
Packit e8bc57
Packit e8bc57
/* Author:  G. Jungman */
Packit e8bc57
Packit e8bc57
#ifndef __GSL_SF_GAMMA_H__
Packit e8bc57
#define __GSL_SF_GAMMA_H__
Packit e8bc57
Packit e8bc57
#include <gsl/gsl_sf_result.h>
Packit e8bc57
Packit e8bc57
#undef __BEGIN_DECLS
Packit e8bc57
#undef __END_DECLS
Packit e8bc57
#ifdef __cplusplus
Packit e8bc57
# define __BEGIN_DECLS extern "C" {
Packit e8bc57
# define __END_DECLS }
Packit e8bc57
#else
Packit e8bc57
# define __BEGIN_DECLS /* empty */
Packit e8bc57
# define __END_DECLS /* empty */
Packit e8bc57
#endif
Packit e8bc57
Packit e8bc57
__BEGIN_DECLS
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Log[Gamma(x)], x not a negative integer
Packit e8bc57
 * Uses real Lanczos method.
Packit e8bc57
 * Returns the real part of Log[Gamma[x]] when x < 0,
Packit e8bc57
 * i.e. Log[|Gamma[x]|].
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM, GSL_EROUND
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_lngamma_e(double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_lngamma(const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Log[Gamma(x)], x not a negative integer
Packit e8bc57
 * Uses real Lanczos method. Determines
Packit e8bc57
 * the sign of Gamma[x] as well as Log[|Gamma[x]|] for x < 0.
Packit e8bc57
 * So Gamma[x] = sgn * Exp[result_lg].
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM, GSL_EROUND
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_lngamma_sgn_e(double x, gsl_sf_result * result_lg, double *sgn);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Gamma(x), x not a negative integer
Packit e8bc57
 * Uses real Lanczos method.
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EROUND
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_gamma_e(const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_gamma(const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Regulated Gamma Function, x > 0
Packit e8bc57
 * Gamma^*(x) = Gamma(x)/(Sqrt[2Pi] x^(x-1/2) exp(-x))
Packit e8bc57
 *            = (1 + 1/(12x) + ...),  x->Inf
Packit e8bc57
 * A useful suggestion of Temme.
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_gammastar_e(const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_gammastar(const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* 1/Gamma(x)
Packit e8bc57
 * Uses real Lanczos method.
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EUNDRFLW, GSL_EROUND
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_gammainv_e(const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_gammainv(const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Log[Gamma(z)] for z complex, z not a negative integer
Packit e8bc57
 * Uses complex Lanczos method. Note that the phase part (arg)
Packit e8bc57
 * is not well-determined when |z| is very large, due
Packit e8bc57
 * to inevitable roundoff in restricting to (-Pi,Pi].
Packit e8bc57
 * This will raise the GSL_ELOSS exception when it occurs.
Packit e8bc57
 * The absolute value part (lnr), however, never suffers.
Packit e8bc57
 *
Packit e8bc57
 * Calculates:
Packit e8bc57
 *   lnr = log|Gamma(z)|
Packit e8bc57
 *   arg = arg(Gamma(z))  in (-Pi, Pi]
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM, GSL_ELOSS
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_lngamma_complex_e(double zr, double zi, gsl_sf_result * lnr, gsl_sf_result * arg);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* x^n / n!
Packit e8bc57
 *
Packit e8bc57
 * x >= 0.0, n >= 0
Packit e8bc57
 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_taylorcoeff_e(const int n, const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_taylorcoeff(const int n, const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* n!
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM, GSL_OVRFLW
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_fact_e(const unsigned int n, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_fact(const unsigned int n);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* n!! = n(n-2)(n-4) ... 
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM, GSL_OVRFLW
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_doublefact_e(const unsigned int n, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_doublefact(const unsigned int n);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* log(n!) 
Packit e8bc57
 * Faster than ln(Gamma(n+1)) for n < 170; defers for larger n.
Packit e8bc57
 *
Packit e8bc57
 * exceptions: none
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_lnfact_e(const unsigned int n, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_lnfact(const unsigned int n);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* log(n!!) 
Packit e8bc57
 *
Packit e8bc57
 * exceptions: none
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_lndoublefact_e(const unsigned int n, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_lndoublefact(const unsigned int n);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* log(n choose m)
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM 
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_lnchoose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_lnchoose(unsigned int n, unsigned int m);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* n choose m
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM, GSL_EOVRFLW
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_choose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_choose(unsigned int n, unsigned int m);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Logarithm of Pochhammer (Apell) symbol
Packit e8bc57
 *   log( (a)_x )
Packit e8bc57
 *   where (a)_x := Gamma[a + x]/Gamma[a]
Packit e8bc57
 *
Packit e8bc57
 * a > 0, a+x > 0
Packit e8bc57
 *
Packit e8bc57
 * exceptions:  GSL_EDOM
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_lnpoch_e(const double a, const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_lnpoch(const double a, const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Logarithm of Pochhammer (Apell) symbol, with sign information.
Packit e8bc57
 *   result = log( |(a)_x| )
Packit e8bc57
 *   sgn    = sgn( (a)_x )
Packit e8bc57
 *   where (a)_x := Gamma[a + x]/Gamma[a]
Packit e8bc57
 *
Packit e8bc57
 * a != neg integer, a+x != neg integer
Packit e8bc57
 *
Packit e8bc57
 * exceptions:  GSL_EDOM
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_lnpoch_sgn_e(const double a, const double x, gsl_sf_result * result, double * sgn);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Pochhammer (Apell) symbol
Packit e8bc57
 *   (a)_x := Gamma[a + x]/Gamma[x]
Packit e8bc57
 *
Packit e8bc57
 * a != neg integer, a+x != neg integer
Packit e8bc57
 *
Packit e8bc57
 * exceptions:  GSL_EDOM, GSL_EOVRFLW
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_poch_e(const double a, const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_poch(const double a, const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Relative Pochhammer (Apell) symbol
Packit e8bc57
 *   ((a,x) - 1)/x
Packit e8bc57
 *   where (a,x) = (a)_x := Gamma[a + x]/Gamma[a]
Packit e8bc57
 *
Packit e8bc57
 * exceptions:  GSL_EDOM
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_pochrel_e(const double a, const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_pochrel(const double a, const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Normalized Incomplete Gamma Function
Packit e8bc57
 *
Packit e8bc57
 * Q(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
Packit e8bc57
 *
Packit e8bc57
 * a >= 0, x >= 0
Packit e8bc57
 *   Q(a,0) := 1
Packit e8bc57
 *   Q(0,x) := 0, x != 0
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_gamma_inc_Q_e(const double a, const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_gamma_inc_Q(const double a, const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Complementary Normalized Incomplete Gamma Function
Packit e8bc57
 *
Packit e8bc57
 * P(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,0,x} ]
Packit e8bc57
 *
Packit e8bc57
 * a > 0, x >= 0
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_gamma_inc_P_e(const double a, const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_gamma_inc_P(const double a, const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Non-normalized Incomplete Gamma Function
Packit e8bc57
 *
Packit e8bc57
 * Gamma(a,x) := Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
Packit e8bc57
 *
Packit e8bc57
 * x >= 0.0
Packit e8bc57
 *   Gamma(a, 0) := Gamma(a)
Packit e8bc57
 *
Packit e8bc57
 * exceptions: GSL_EDOM
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_gamma_inc_e(const double a, const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_gamma_inc(const double a, const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Logarithm of Beta Function
Packit e8bc57
 * Log[B(a,b)]
Packit e8bc57
 *
Packit e8bc57
 * a > 0, b > 0
Packit e8bc57
 * exceptions: GSL_EDOM
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_lnbeta_e(const double a, const double b, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_lnbeta(const double a, const double b);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Beta Function
Packit e8bc57
 * B(a,b)
Packit e8bc57
 *
Packit e8bc57
 * a > 0, b > 0
Packit e8bc57
 * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_beta_e(const double a, const double b, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_beta(const double a, const double b);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* Normalized Incomplete Beta Function
Packit e8bc57
 * B_x(a,b)/B(a,b)
Packit e8bc57
 *
Packit e8bc57
 * a > 0, b > 0, 0 <= x <= 1
Packit e8bc57
 * exceptions: GSL_EDOM, GSL_EUNDRFLW
Packit e8bc57
 */
Packit e8bc57
int gsl_sf_beta_inc_e(const double a, const double b, const double x, gsl_sf_result * result);
Packit e8bc57
double gsl_sf_beta_inc(const double a, const double b, const double x);
Packit e8bc57
Packit e8bc57
Packit e8bc57
/* The maximum x such that gamma(x) is not
Packit e8bc57
 * considered an overflow.
Packit e8bc57
 */
Packit e8bc57
#define GSL_SF_GAMMA_XMAX  171.0
Packit e8bc57
Packit e8bc57
Packit e8bc57
__END_DECLS
Packit e8bc57
Packit e8bc57
#endif /* __GSL_SF_GAMMA_H__ */