29#ifndef gslInterpolator_hpp
30#define gslInterpolator_hpp
33#include <gsl/gsl_interp.h>
34#include <gsl/gsl_errno.h>
36#include "../mxlib.hpp"
46template <
typename _realT>
53 return ::gsl_interp_linear;
61template <
typename _realT>
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" );
109 std::vector<realT> &
yin
147template <
typename interpT>
152template <
typename interpT>
158template <
typename interpT>
161 setup(
xin.data(),
yin.data(),
xin.size() );
164template <
typename interpT>
167 if( m_interp !=
nullptr )
169 if( m_acc !=
nullptr )
173template <
typename interpT>
176 if( m_interp !=
nullptr )
178 if( m_acc !=
nullptr )
209template <
typename interpT>
212 if(
xin.size() !=
yin.size() )
216 setup(
xin.data(),
yin.data(),
xin.size() );
219template <
typename interpT>
Augments an exception with the source file and line.
Class to manage interpolation using the GSL interpolation library.
gslInterpolator(std::vector< realT > &xin, std::vector< realT > &yin)
Vector constructor.
gsl_interp_accel * m_acc
the gsl interpolation accelerator structure
void setup(std::vector< realT > &xin, std::vector< realT > &yin)
Setup the interpolator for the supplied data vectors.
~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.
gslInterpolator(realT *xin, realT *yin, size_t Nin)
Raw pointer 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.
constexpr floatT six_fifths()
Return 6/5 in the specified precision.
GSL Linear Interpolation.
GSL Steffen Interpolation.