double gamma ( double x ) { double ret; if ( x<=0.0 ) { ret = 0.0; } #if 0 else if ( x<0.5 ) { ret = gamma_kernel(x+1.0)/x; /* Puts x in [0.5,1.5) */ } else if ( x<1.5 ) { ret = gamma_kernel(x); /* Puts x in [0.5,1.5) */ } else { ret = (x-1.0) * gamma(x-1.0); /* Recurse till x in [0.5,1.5) */ } #else else if ( x<1.0 )
double gamma ( double x ) { double ret; if ( x<=0.0 ) { ret = 0.0; } else if ( x<1.0 ) { ret = gamma_kernel(x); } else { ret = (x-1.0) * gamma(x-1.0); } END: return ret; }
else if ( x<0.5 ) { ret = gamma_kernel(x+1.0)/x; /* Puts x in [0.5,1.5) */ } else if ( x<1.5 ) { ret = gamma_kernel(x); /* Puts x in [0.5,1.5) */ } else { ret = (x-1.0) * gamma(x-1.0); /* Recurse till x in [0.5,1.5) */ } #else else if ( x<1.0 ) { ret = gamma_kernel(x); } else { ret = (x-1.0) * gamma(x-1.0); } #endif END: return ret; } double my_pow_f ( double base, double exp ) { return exponential ( exp * natural_log(base) ); }