22#include "ProbTools/NumRecipes.h"
41 double x, y, tmp, ser;
42 static double cof[6] = { 76.18009172947146, -86.50532032941677, 24.01409824083091,
43 -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5 };
48 tmp -= ( x + 0.5 ) * log( tmp );
49 ser = 1.000000000190015;
50 for ( j = 0; j <= 5; j++ ) ser += cof[j] / ++y;
51 return -tmp + log( 2.5066282746310005 * ser / x );
55 double gamser, gammcf, gln;
57 if ( x < 0.0 || a <= 0.0 )
58 std::cout <<
"ErrMsg(error)"
59 <<
" Invalid arguments in routine gammp x=" << x <<
" a=" << a << endl;
60 if ( x < ( a + 1.0 ) )
62 gser( &gamser, a, x, &gln );
67 gcf( &gammcf, a, x, &gln );
73 double gamser, gammcf, gln;
75 if ( x < 0.0 || a <= 0.0 ) recipesErr(
" Invalid arguments in routine GAMMQ" );
76 if ( x < ( a + 1.0 ) )
78 gser( &gamser, a, x, &gln );
83 gcf( &gammcf, a, x, &gln );
90 double gold = 0.0, g, fac = 1.0, b1 = 1.0;
91 double b0 = 0.0, anf, ana, an, a1,
a0 = 1.0;
99 a0 = ( a1 +
a0 * ana ) * fac;
100 b0 = ( b1 + b0 * ana ) * fac;
102 a1 = x *
a0 + anf * a1;
103 b1 = x * b0 + anf * b1;
110 *gammcf =
exp( -x + a * log( x ) - ( *gln ) ) * g;
116 recipesErr(
" a too large, NUMREC_ITMAX too small in routine GCF" );
126 if ( x < 0.0 ) recipesErr(
" x less than 0 in routine GSER" );
141 *gamser = sum *
exp( -x + a * log( x ) - ( *gln ) );
145 recipesErr(
" a too large, NUMREC_ITMAX too small in routine GSER" );
150void NumRecipes::recipesErr(
const char* c ) {
151 std::cout <<
"ErrMsg(fatal)"
152 <<
" Numerical Recipes run-time error...\n"
153 << c <<
"\n ...now exiting to system..." << std::endl;
character *LEPTONflag integer iresonances real zeta5 real a0
EvtComplex exp(const EvtComplex &c)
static double gammq(double a, double x)
static void gser(double *gamser, double a, double x, double *gln)
static double gammln(double x)
static void gcf(double *gammcf, double a, double x, double *gln)
static double gammp(double a, double x)