29#ifndef gslInterpolator_hpp
30#define gslInterpolator_hpp
33#include <gsl/gsl_interp.h>
34#include <gsl/gsl_errno.h>
46template <
typename _realT>
51 static const gsl_interp_type *interpolator()
53 return ::gsl_interp_linear;
61template <
typename _realT>
66 static const gsl_interp_type *interpolator()
68 return ::gsl_interp_steffen;
80template <
typename interpT>
84 typedef typename interpT::realT realT;
86 static_assert( std::is_same<double, typename std::remove_cv<realT>::type>::value,
87 "GSL Interpolation only works with double" );
91 gsl_interp_accel *
m_acc{
nullptr };
109 std::vector<realT> &yin
134 void setup( std::vector<realT>
147template <
typename interpT>
152template <
typename interpT>
155 setup( xin, yin, Nin );
158template <
typename interpT>
161 setup( xin.data(), yin.data(), xin.size() );
164template <
typename interpT>
169 if(
m_acc !=
nullptr )
170 gsl_interp_accel_free(
m_acc );
173template <
typename interpT>
178 if(
m_acc !=
nullptr )
179 gsl_interp_accel_free(
m_acc );
181 m_interp = gsl_interp_alloc( interpT::interpolator(), Nin );
187 m_acc = gsl_interp_accel_alloc();
193 int errv = gsl_interp_init(
m_interp, xin, yin, Nin );
199 errv = gsl_interp_accel_reset(
m_acc );
209template <
typename interpT>
212 if( xin.size() != yin.size() )
216 setup( xin.data(), yin.data(), xin.size() );
219template <
typename interpT>
224 if( errv != 0 && errv != GSL_EDOM )
Augments an exception with the source file and line.
Class to manage interpolation using the GSL interpolation library.
gsl_interp_accel * m_acc
the gsl interpolation accelerator structure
~gslInterpolator()
Destructor.
realT * m_xin
the input x data
realT operator()(const realT &x)
Calculate the interpolated function value at a point.
gslInterpolator()
Default constructor.
gsl_interp * m_interp
the gsl interpolator structure
void setup(realT *xin, realT *yin, size_t Nin)
Setup the interpolator for the supplied data pointers.
realT * m_yin
the input y data
@ sizeerr
A size was invalid or calculated incorrectly.
@ allocerr
An error occurred during memory allocation.
@ liberr
An error was returned by a library.
Declarations of some libarary wide utilities.
GSL Linear Interpolation.
GSL Steffen Interpolation.