Example for usage of GSL, GNU Scientific Library
- Author
- MIP
#include <bias_config.h>
#ifdef BIAS_HAVE_GSL
#include <Base/Math/Random.hh>
#include <MathAlgo/GSL.hh>
using namespace BIAS;
using namespace std;
# include <gsl/gsl_cdf.h>
int TestGSL(){
const double x (5.678);
const double nu (3.21);
const double groundtruth(0.85341575204989784);
const double eps (0.0000000000001);
double val = gsl_cdf_chisq_P (x, nu);
if (fabs(val-groundtruth)>eps){
return -1;
} else {
return 0;
}
}
int main(int , char ** )
{
const int count=100;
const int deg_freedom = 2;
double x;
for (int i=0; i<count; i++){
cout << setw(13) << setprecision(3) << x
<< setw(13) << setprecision(3)
<< endl;
}
return TestGSL();
}
#endif // BIAS_HAVE_GSL