55 double v = LnGamma(z);
69 if (a <= 0 || x <= 0)
return 0;
71 if (x < (a+1))
return GamSer(a,x);
72 else return GamCf(a,x);
76 double MyGamma::GamCf(
double a,
double x)
88 double fpmin = 1.e-30;
90 if (a <= 0 || x <= 0)
return 0;
92 double gln = LnGamma(a);
98 for (
int i=1; i<=itmax; i++) {
99 an = double(-i)*(double(i)-
a);
102 if (Abs(d) < fpmin) d = fpmin;
104 if (Abs(c) < fpmin) c = fpmin;
108 if (Abs(del-1) <
eps)
break;
111 double v = Exp(-x+a*Log(x)-gln)*h;
116 double MyGamma::GamSer(
double a,
double x)
129 if (a <= 0 || x <= 0)
return 0;
131 double gln = LnGamma(a);
135 for (
int n=1;
n<=itmax;
n++) {
139 if (MyGamma::Abs(del) < Abs(sum*eps))
break;
142 double v = sum*Exp(-x+a*Log(x)-gln);
147 double MyGamma::LnGamma(
double z)
163 double c[7] = { 2.5066282746310005, 76.18009172947146, -86.50532032941677
164 ,24.01409824083091, -1.231739572450155, 0.1208650973866179e-2
165 ,-0.5395239384953e-5};
170 tmp = (x+0.5)*Log(tmp)-tmp;
171 double ser = 1.000000000190015;
172 for (
int i=1; i<7; i++) {
176 double v = tmp+Log(c[0]*ser/x);
std::vector< ExP01TrackerHit * > a
static const G4double eps