#include <NumRecipes.h>
Static Public Member Functions | |
static double | gammln (double x) |
static double | gammq (double a, double x) |
static double | gammp (double a, double x) |
static void | gcf (double *gammcf, double a, double x, double *gln) |
static void | gser (double *gamser, double a, double x, double *gln) |
static double | gammln (double x) |
static double | gammq (double a, double x) |
static double | gammp (double a, double x) |
static void | gcf (double *gammcf, double a, double x, double *gln) |
static void | gser (double *gamser, double a, double x, double *gln) |
Static Private Member Functions | |
static void | recipesErr (const char *c) |
static void | recipesErr (const char *c) |
Definition at line 30 of file NumRecipes.h.
static double NumRecipes::gammln | ( | double | x | ) | [static] |
double NumRecipes::gammln | ( | double | x | ) | [static] |
Definition at line 40 of file NumRecipes.cxx.
References ganga-rec::j, and x.
Referenced by ChisqConsistency::ChisqConsistency(), gcf(), and gser().
00041 { 00042 double x,y,tmp,ser; 00043 static double cof[6]={76.18009172947146,-86.50532032941677, 00044 24.01409824083091,-1.231739572450155, 00045 0.1208650973866179e-2,-0.5395239384953e-5}; 00046 int j; 00047 00048 y=x=xx; 00049 tmp=x+5.5; 00050 tmp -= (x+0.5)*log(tmp); 00051 ser=1.000000000190015; 00052 for (j=0;j<=5;j++) ser += cof[j]/++y; 00053 return -tmp+log(2.5066282746310005*ser/x); 00054 }
static double NumRecipes::gammp | ( | double | a, | |
double | x | |||
) | [static] |
double NumRecipes::gammp | ( | double | a, | |
double | x | |||
) | [static] |
Definition at line 57 of file NumRecipes.cxx.
00058 { 00059 double gamser,gammcf,gln; 00060 00061 if (x < 0.0 || a <= 0.0) std::cout<<"ErrMsg(error)" <<" Invalid arguments in routine gammp x=" << x << " a=" << a << endl; 00062 if (x < (a+1.0)) { 00063 gser(&gamser,a,x,&gln); 00064 return gamser; 00065 } else { 00066 gcf(&gammcf,a,x,&gln); 00067 return 1.0-gammcf; 00068 } 00069 }
static double NumRecipes::gammq | ( | double | a, | |
double | x | |||
) | [static] |
double NumRecipes::gammq | ( | double | a, | |
double | x | |||
) | [static] |
Definition at line 72 of file NumRecipes.cxx.
References gcf(), gser(), and recipesErr().
Referenced by ChisqConsistency::ChisqConsistency().
00073 { 00074 double gamser,gammcf,gln; 00075 00076 if (x < 0.0 || a <= 0.0) recipesErr(" Invalid arguments in routine GAMMQ"); 00077 if (x < (a+1.0)) { 00078 gser(&gamser,a,x,&gln); 00079 return 1.0-gamser; 00080 } else { 00081 gcf(&gammcf,a,x,&gln); 00082 return gammcf; 00083 } 00084 }
static void NumRecipes::gcf | ( | double * | gammcf, | |
double | a, | |||
double | x, | |||
double * | gln | |||
) | [static] |
void NumRecipes::gcf | ( | double * | gammcf, | |
double | a, | |||
double | x, | |||
double * | gln | |||
) | [static] |
Definition at line 86 of file NumRecipes.cxx.
References a0, exp(), gammln(), NUMREC_EPS, NUMREC_ITMAX, and recipesErr().
Referenced by gammp(), and gammq().
00087 { 00088 int n; 00089 double gold=0.0,g,fac=1.0,b1=1.0; 00090 double b0=0.0,anf,ana,an,a1,a0=1.0; 00091 00092 *gln=gammln(a); 00093 a1=x; 00094 for (n=1;n<=NUMREC_ITMAX;n++) { 00095 an=(double) n; 00096 ana=an-a; 00097 a0=(a1+a0*ana)*fac; 00098 b0=(b1+b0*ana)*fac; 00099 anf=an*fac; 00100 a1=x*a0+anf*a1; 00101 b1=x*b0+anf*b1; 00102 if (a1) { 00103 fac=1.0/a1; 00104 g=b1*fac; 00105 if (fabs((g-gold)/g) < NUMREC_EPS) { 00106 *gammcf=exp(-x+a*log(x)-(*gln))*g; 00107 return; 00108 } 00109 gold=g; 00110 } 00111 } 00112 recipesErr(" a too large, NUMREC_ITMAX too small in routine GCF"); 00113 }
static void NumRecipes::gser | ( | double * | gamser, | |
double | a, | |||
double | x, | |||
double * | gln | |||
) | [static] |
void NumRecipes::gser | ( | double * | gamser, | |
double | a, | |||
double | x, | |||
double * | gln | |||
) | [static] |
Definition at line 115 of file NumRecipes.cxx.
References exp(), gammln(), NUMREC_EPS, NUMREC_ITMAX, and recipesErr().
Referenced by gammp(), and gammq().
00116 { 00117 int n; 00118 double sum,del,ap; 00119 00120 *gln=gammln(a); 00121 if (x <= 0.0) { 00122 if (x < 0.0) recipesErr(" x less than 0 in routine GSER"); 00123 *gamser=0.0; 00124 return; 00125 } else { 00126 ap=a; 00127 del=sum=1.0/a; 00128 for (n=1;n<=NUMREC_ITMAX;n++) { 00129 ap += 1.0; 00130 del *= x/ap; 00131 sum += del; 00132 if (fabs(del) < fabs(sum)*NUMREC_EPS) { 00133 *gamser=sum*exp(-x+a*log(x)-(*gln)); 00134 return; 00135 } 00136 } 00137 recipesErr(" a too large, NUMREC_ITMAX too small in routine GSER"); 00138 return; 00139 } 00140 }
static void NumRecipes::recipesErr | ( | const char * | c | ) | [static, private] |
void NumRecipes::recipesErr | ( | const char * | c | ) | [static, private] |
Definition at line 142 of file NumRecipes.cxx.
Referenced by gammq(), gcf(), and gser().
00143 { 00144 std::cout<<"ErrMsg(fatal)" << " Numerical Recipes run-time error...\n" << c 00145 << "\n ...now exiting to system..." << std::endl; 00146 ::abort(); 00147 }