Skip to content
Snippets Groups Projects
Commit 05f5dbc2 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

+ functions fac, cata

parent 2d515946
No related branches found
No related tags found
No related merge requests found
......@@ -92,6 +92,14 @@ double func_coth(double v) { double t=tanh(v); return t==0?0:1/t;}
double func_j0(double v) { return v==0 ? 1 : sin(v)/v;}
double func_fac(double v) { return v>-.5 ? gsl_sf_gamma(round(v+1)) : 0; }
double func_cata(double v) {
if ( v<=-.5 )
return 0;
double x = round(v);
return exp( gsl_sf_lngamma( 2*x+1 ) - gsl_sf_lngamma( x+1 ) -
gsl_sf_lngamma( x+2 ) ); }
double func_gamma(double v) { return v>0 ? gsl_sf_gamma(v) : 0; }
double func_lgamma(double v) { return v>0 ? gsl_sf_lngamma(v) : 0; }
// could be extended to non-integer negative arguments...
......@@ -451,6 +459,10 @@ void NFunctions::initialize(void)
"(x): hyperbolic tangent of x" ).register_me();
CFunc( "j0", func_j0, 0, 0,
"(x): spherical Bessel function x" ).register_me();
CFunc( "fac",func_fac, 0, 0,
"(x): factorial of nearest integer of x" ).register_me();
CFunc( "cata",func_cata, 0, 0,
"(x): Catalan number of nearest integer of x" ).register_me();
CFunc( "gamma",func_gamma, 0, 0,
"(x): gamma function of x (i.e. factorial of x-1)" ).register_me();
CFunc( "lgamma",func_lgamma, 0, 0,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment