float gammp(float a, float x) { if(x < 0.0 || a <= 0.0) printf("bad args in gammp\n"); if(x == 0.0) return 0.0; else if((int) a >= ASWITCH) return gammpapprox(a, x, 1); else if(x < a + 1.0) return gser(a, x); else return 1.0 - gcf(a, x); }
double gammq(double a, double x) { if(x < 0.0 || a <= 0.0) printf("bad args in gammq\n"); if(x == 0.0) return 1.0; else if((int) a >= ASWITCH) return gammpapprox(a, x, 0); else if(x < a + 1.0) return 1.0 - gser(a, x); else return gcf(a, x); }
double gammp(const double a, double x) { static const int ASWITCH = 100; if(x < 0.0 || a <= 0.0) { std::cout << "Bad value in Fgamma!"; return 0.0; } if(x == 0.0) { return 0.0; } else if(a >= ASWITCH) { return gammpapprox(a,x,1); /* use quadrature */ } else if(x < a + 1.0) { return gser(a,x); /* use the series expansion */ } else { return 1.0 - gcf(a,x); /* use the continued fraction expansion */ } }