41 GSLInterpolator::GSLInterpolator (
unsigned int size, Interpolation::Type type) :
50 case ROOT::Math::Interpolation::kLINEAR :
51 fInterpType = gsl_interp_linear;
53 case ROOT::Math::Interpolation::kPOLYNOMIAL :
54 fInterpType = gsl_interp_polynomial;
57 case ROOT::Math::Interpolation::kCSPLINE :
58 fInterpType = gsl_interp_cspline ;
60 case ROOT::Math::Interpolation::kCSPLINE_PERIODIC :
61 fInterpType = gsl_interp_cspline_periodic ;
63 case ROOT::Math::Interpolation::kAKIMA :
64 fInterpType = gsl_interp_akima;
66 case ROOT::Math::Interpolation::kAKIMA_PERIODIC :
67 fInterpType = gsl_interp_akima_periodic;
71 fInterpType = gsl_interp_cspline;
76 if (size >= fInterpType->min_size)
77 fSpline = gsl_spline_alloc( fInterpType, size);
81 bool GSLInterpolator::Init(
unsigned int size,
const double *x,
const double * y) {
85 fSpline = gsl_spline_alloc( fInterpType, size);
88 gsl_interp * interp = fSpline->interp;
89 if (size != interp->size) {
91 gsl_spline_free(fSpline);
92 fSpline = gsl_spline_alloc( fInterpType, size);
96 if (!fSpline)
return false;
98 int iret = gsl_spline_init( fSpline , x , y , size );
99 if (iret != 0)
return false;
102 fAccel = gsl_interp_accel_alloc() ;
104 gsl_interp_accel_reset(fAccel);
108 assert (fSpline != 0);
109 assert (fAccel != 0);
111 fResetNErrors =
true;
115 GSLInterpolator::~GSLInterpolator()
118 if (fSpline != 0) gsl_spline_free(fSpline);
119 if (fAccel != 0) gsl_interp_accel_free( fAccel);
122 GSLInterpolator::GSLInterpolator(
const GSLInterpolator &)
127 GSLInterpolator & GSLInterpolator::operator = (
const GSLInterpolator &rhs)
130 if (
this == &rhs)
return *
this;