31 #ifndef ROOT_Math_GSLInterpolator
32 #define ROOT_Math_GSLInterpolator
40 #include "gsl/gsl_interp.h"
41 #include "gsl/gsl_spline.h"
43 #include "gsl/gsl_errno.h"
55 class GSLInterpolator {
59 GSLInterpolator(
unsigned int ndata, Interpolation::Type type);
61 GSLInterpolator(
const Interpolation::Type type,
const std::vector<double> & x,
const std::vector<double> & y );
62 virtual ~GSLInterpolator();
66 GSLInterpolator(
const GSLInterpolator &);
67 GSLInterpolator & operator = (
const GSLInterpolator &);
71 bool Init(
unsigned int ndata,
const double *x,
const double *y);
73 double Eval(
double x)
const
77 static unsigned int nErrors = 0;
78 int ierr = gsl_spline_eval_e(fSpline, x, fAccel, &y);
81 nErrors = 0, fResetNErrors =
false;
86 MATH_WARN_MSG(
"GSLInterpolator::Eval", gsl_strerror(ierr));
88 MATH_WARN_MSG(
"GSLInterpolator::Eval",
"Suppressing additional warnings");
95 double Deriv(
double x)
const
99 static unsigned int nErrors = 0;
100 int ierr = gsl_spline_eval_deriv_e(fSpline, x, fAccel, &deriv);
103 nErrors = 0, fResetNErrors =
false;
108 MATH_WARN_MSG(
"GSLInterpolator::Deriv", gsl_strerror(ierr));
110 MATH_WARN_MSG(
"GSLInterpolator::Deriv",
"Suppressing additional warnings");
117 double Deriv2(
double x)
const {
120 static unsigned int nErrors = 0;
121 int ierr = gsl_spline_eval_deriv2_e(fSpline, x, fAccel, &deriv2);
124 nErrors = 0, fResetNErrors =
false;
129 MATH_WARN_MSG(
"GSLInterpolator::Deriv2", gsl_strerror(ierr));
131 MATH_WARN_MSG(
"GSLInterpolator::Deriv2",
"Suppressing additional warnings");
138 double Integ(
double a,
double b)
const {
144 static unsigned int nErrors = 0;
145 int ierr = gsl_spline_eval_integ_e(fSpline, a, b, fAccel, &result);
148 nErrors = 0, fResetNErrors =
false;
153 MATH_WARN_MSG(
"GSLInterpolator::Integ", gsl_strerror(ierr));
155 MATH_WARN_MSG(
"GSLInterpolator::Integ",
"Suppressing additional warnings");
163 return fInterpType->name;
168 mutable bool fResetNErrors;
169 gsl_interp_accel * fAccel;
170 gsl_spline * fSpline;
171 const gsl_interp_type * fInterpType;