Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:03:53

0001 /* specfunc/gsl_sf_gamma.h
0002  * 
0003  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
0004  * 
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 3 of the License, or (at
0008  * your option) any later version.
0009  * 
0010  * This program is distributed in the hope that it will be useful, but
0011  * WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * General Public License for more details.
0014  * 
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 /* Author:  G. Jungman */
0021 
0022 #ifndef __GSL_SF_GAMMA_H__
0023 #define __GSL_SF_GAMMA_H__
0024 
0025 #include <gsl/gsl_sf_result.h>
0026 
0027 #undef __BEGIN_DECLS
0028 #undef __END_DECLS
0029 #ifdef __cplusplus
0030 # define __BEGIN_DECLS extern "C" {
0031 # define __END_DECLS }
0032 #else
0033 # define __BEGIN_DECLS /* empty */
0034 # define __END_DECLS /* empty */
0035 #endif
0036 
0037 __BEGIN_DECLS
0038 
0039 
0040 /* Log[Gamma(x)], x not a negative integer
0041  * Uses real Lanczos method.
0042  * Returns the real part of Log[Gamma[x]] when x < 0,
0043  * i.e. Log[|Gamma[x]|].
0044  *
0045  * exceptions: GSL_EDOM, GSL_EROUND
0046  */
0047 int gsl_sf_lngamma_e(double x, gsl_sf_result * result);
0048 double gsl_sf_lngamma(const double x);
0049 
0050 
0051 /* Log[Gamma(x)], x not a negative integer
0052  * Uses real Lanczos method. Determines
0053  * the sign of Gamma[x] as well as Log[|Gamma[x]|] for x < 0.
0054  * So Gamma[x] = sgn * Exp[result_lg].
0055  *
0056  * exceptions: GSL_EDOM, GSL_EROUND
0057  */
0058 int gsl_sf_lngamma_sgn_e(double x, gsl_sf_result * result_lg, double *sgn);
0059 
0060 
0061 /* Gamma(x), x not a negative integer
0062  * Uses real Lanczos method.
0063  *
0064  * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EROUND
0065  */
0066 int gsl_sf_gamma_e(const double x, gsl_sf_result * result);
0067 double gsl_sf_gamma(const double x);
0068 
0069 
0070 /* Regulated Gamma Function, x > 0
0071  * Gamma^*(x) = Gamma(x)/(Sqrt[2Pi] x^(x-1/2) exp(-x))
0072  *            = (1 + 1/(12x) + ...),  x->Inf
0073  * A useful suggestion of Temme.
0074  *
0075  * exceptions: GSL_EDOM
0076  */
0077 int gsl_sf_gammastar_e(const double x, gsl_sf_result * result);
0078 double gsl_sf_gammastar(const double x);
0079 
0080 
0081 /* 1/Gamma(x)
0082  * Uses real Lanczos method.
0083  *
0084  * exceptions: GSL_EUNDRFLW, GSL_EROUND
0085  */
0086 int gsl_sf_gammainv_e(const double x, gsl_sf_result * result);
0087 double gsl_sf_gammainv(const double x);
0088 
0089 
0090 /* Log[Gamma(z)] for z complex, z not a negative integer
0091  * Uses complex Lanczos method. Note that the phase part (arg)
0092  * is not well-determined when |z| is very large, due
0093  * to inevitable roundoff in restricting to (-Pi,Pi].
0094  * This will raise the GSL_ELOSS exception when it occurs.
0095  * The absolute value part (lnr), however, never suffers.
0096  *
0097  * Calculates:
0098  *   lnr = log|Gamma(z)|
0099  *   arg = arg(Gamma(z))  in (-Pi, Pi]
0100  *
0101  * exceptions: GSL_EDOM, GSL_ELOSS
0102  */
0103 int gsl_sf_lngamma_complex_e(double zr, double zi, gsl_sf_result * lnr, gsl_sf_result * arg);
0104 
0105 
0106 /* x^n / n!
0107  *
0108  * x >= 0.0, n >= 0
0109  * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
0110  */
0111 int gsl_sf_taylorcoeff_e(const int n, const double x, gsl_sf_result * result);
0112 double gsl_sf_taylorcoeff(const int n, const double x);
0113 
0114 
0115 /* n!
0116  *
0117  * exceptions: GSL_EDOM, GSL_EOVRFLW
0118  */
0119 int gsl_sf_fact_e(const unsigned int n, gsl_sf_result * result);
0120 double gsl_sf_fact(const unsigned int n);
0121 
0122 
0123 /* n!! = n(n-2)(n-4) ... 
0124  *
0125  * exceptions: GSL_EDOM, GSL_EOVRFLW
0126  */
0127 int gsl_sf_doublefact_e(const unsigned int n, gsl_sf_result * result);
0128 double gsl_sf_doublefact(const unsigned int n);
0129 
0130 
0131 /* log(n!) 
0132  * Faster than ln(Gamma(n+1)) for n < 170; defers for larger n.
0133  *
0134  * exceptions: none
0135  */
0136 int gsl_sf_lnfact_e(const unsigned int n, gsl_sf_result * result);
0137 double gsl_sf_lnfact(const unsigned int n);
0138 
0139 
0140 /* log(n!!) 
0141  *
0142  * exceptions: none
0143  */
0144 int gsl_sf_lndoublefact_e(const unsigned int n, gsl_sf_result * result);
0145 double gsl_sf_lndoublefact(const unsigned int n);
0146 
0147 
0148 /* log(n choose m)
0149  *
0150  * exceptions: GSL_EDOM 
0151  */
0152 int gsl_sf_lnchoose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
0153 double gsl_sf_lnchoose(unsigned int n, unsigned int m);
0154 
0155 
0156 /* n choose m
0157  *
0158  * exceptions: GSL_EDOM, GSL_EOVRFLW
0159  */
0160 int gsl_sf_choose_e(unsigned int n, unsigned int m, gsl_sf_result * result);
0161 double gsl_sf_choose(unsigned int n, unsigned int m);
0162 
0163 
0164 /* Logarithm of Pochhammer (Apell) symbol
0165  *   log( (a)_x )
0166  *   where (a)_x := Gamma[a + x]/Gamma[a]
0167  *
0168  * a > 0, a+x > 0
0169  *
0170  * exceptions:  GSL_EDOM
0171  */
0172 int gsl_sf_lnpoch_e(const double a, const double x, gsl_sf_result * result);
0173 double gsl_sf_lnpoch(const double a, const double x);
0174 
0175 
0176 /* Logarithm of Pochhammer (Apell) symbol, with sign information.
0177  *   result = log( |(a)_x| )
0178  *   sgn    = sgn( (a)_x )
0179  *   where (a)_x := Gamma[a + x]/Gamma[a]
0180  *
0181  * a != neg integer, a+x != neg integer
0182  *
0183  * exceptions:  GSL_EDOM
0184  */
0185 int gsl_sf_lnpoch_sgn_e(const double a, const double x, gsl_sf_result * result, double * sgn);
0186 
0187 
0188 /* Pochhammer (Apell) symbol
0189  *   (a)_x := Gamma[a + x]/Gamma[x]
0190  *
0191  * a != neg integer, a+x != neg integer
0192  *
0193  * exceptions:  GSL_EDOM, GSL_EOVRFLW
0194  */
0195 int gsl_sf_poch_e(const double a, const double x, gsl_sf_result * result);
0196 double gsl_sf_poch(const double a, const double x);
0197 
0198 
0199 /* Relative Pochhammer (Apell) symbol
0200  *   ((a,x) - 1)/x
0201  *   where (a,x) = (a)_x := Gamma[a + x]/Gamma[a]
0202  *
0203  * exceptions:  GSL_EDOM
0204  */
0205 int gsl_sf_pochrel_e(const double a, const double x, gsl_sf_result * result);
0206 double gsl_sf_pochrel(const double a, const double x);
0207 
0208 
0209 /* Normalized Incomplete Gamma Function
0210  *
0211  * Q(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
0212  *
0213  * a >= 0, x >= 0
0214  *   Q(a,0) := 1
0215  *   Q(0,x) := 0, x != 0
0216  *
0217  * exceptions: GSL_EDOM
0218  */
0219 int gsl_sf_gamma_inc_Q_e(const double a, const double x, gsl_sf_result * result);
0220 double gsl_sf_gamma_inc_Q(const double a, const double x);
0221 
0222 
0223 /* Complementary Normalized Incomplete Gamma Function
0224  *
0225  * P(a,x) = 1/Gamma(a) Integral[ t^(a-1) e^(-t), {t,0,x} ]
0226  *
0227  * a > 0, x >= 0
0228  *
0229  * exceptions: GSL_EDOM
0230  */
0231 int gsl_sf_gamma_inc_P_e(const double a, const double x, gsl_sf_result * result);
0232 double gsl_sf_gamma_inc_P(const double a, const double x);
0233 
0234 
0235 /* Non-normalized Incomplete Gamma Function
0236  *
0237  * Gamma(a,x) := Integral[ t^(a-1) e^(-t), {t,x,Infinity} ]
0238  *
0239  * x >= 0.0
0240  *   Gamma(a, 0) := Gamma(a)
0241  *
0242  * exceptions: GSL_EDOM
0243  */
0244 int gsl_sf_gamma_inc_e(const double a, const double x, gsl_sf_result * result);
0245 double gsl_sf_gamma_inc(const double a, const double x);
0246 
0247 
0248 /* Logarithm of Beta Function
0249  * Log[B(a,b)]
0250  *
0251  * a > 0, b > 0
0252  * exceptions: GSL_EDOM
0253  */
0254 int gsl_sf_lnbeta_e(const double a, const double b, gsl_sf_result * result);
0255 double gsl_sf_lnbeta(const double a, const double b);
0256 
0257 int gsl_sf_lnbeta_sgn_e(const double x, const double y, gsl_sf_result * result, double * sgn);
0258 
0259 
0260 /* Beta Function
0261  * B(a,b)
0262  *
0263  * a > 0, b > 0
0264  * exceptions: GSL_EDOM, GSL_EOVRFLW, GSL_EUNDRFLW
0265  */
0266 int gsl_sf_beta_e(const double a, const double b, gsl_sf_result * result);
0267 double gsl_sf_beta(const double a, const double b);
0268 
0269 
0270 /* Normalized Incomplete Beta Function
0271  * B_x(a,b)/B(a,b)
0272  *
0273  * a > 0, b > 0, 0 <= x <= 1
0274  * exceptions: GSL_EDOM, GSL_EUNDRFLW
0275  */
0276 int gsl_sf_beta_inc_e(const double a, const double b, const double x, gsl_sf_result * result);
0277 double gsl_sf_beta_inc(const double a, const double b, const double x);
0278 
0279 
0280 /* The maximum x such that gamma(x) is not
0281  * considered an overflow.
0282  */
0283 #define GSL_SF_GAMMA_XMAX  171.0
0284 
0285 /* The maximum n such that gsl_sf_fact(n) does not give an overflow. */
0286 #define GSL_SF_FACT_NMAX 170
0287 
0288 /* The maximum n such that gsl_sf_doublefact(n) does not give an overflow. */
0289 #define GSL_SF_DOUBLEFACT_NMAX 297
0290 
0291 __END_DECLS
0292 
0293 #endif /* __GSL_SF_GAMMA_H__ */