mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
mx::math::gslInterpolator< interpT > Class Template Reference

template<typename interpT>
class mx::math::gslInterpolator< interpT >

Class to manage interpolation using the GSL interpolation library.

Template Parameters
interpTis the interpolation type, which also specifies the floating point precision.

Definition at line 81 of file gslInterpolator.hpp.

#include <math/gslInterpolator.hpp>

Public Member Functions

 gslInterpolator ()
 Default constructor.
 gslInterpolator (realT *xin, realT *yin, size_t Nin)
 Raw pointer constructor.
 gslInterpolator (std::vector< realT > &xin, std::vector< realT > &yin)
 Vector constructor.
 ~gslInterpolator ()
 Destructor.
void setup (realT *xin, realT *yin, size_t Nin)
 Setup the interpolator for the supplied data pointers.
void setup (std::vector< realT > &xin, std::vector< realT > &yin)
 Setup the interpolator for the supplied data vectors.
realT operator() (const realT &x)
 Calculate the interpolated function value at a point.

Protected Attributes

gsl_interp * m_interp { nullptr }
 the gsl interpolator structure
gsl_interp_accel * m_acc { nullptr }
 the gsl interpolation accelerator structure
realT * m_xin
 the input x data
realT * m_yin
 the input y data

Constructor & Destructor Documentation

◆ gslInterpolator() [1/3]

template<typename interpT>
mx::math::gslInterpolator< interpT >::gslInterpolator ( )

Default constructor.

Definition at line 148 of file gslInterpolator.hpp.

◆ gslInterpolator() [2/3]

template<typename interpT>
mx::math::gslInterpolator< interpT >::gslInterpolator ( realT * xin,
realT * yin,
size_t Nin )

Raw pointer constructor.

Parameters
[in]xinthe input x data, this pointer is stored and must remain valid
[in]yinthe input y data, this pointer is stored and must remain valid
[in]Ninthe size of data vectors

Definition at line 153 of file gslInterpolator.hpp.

References setup().

◆ gslInterpolator() [3/3]

template<typename interpT>
mx::math::gslInterpolator< interpT >::gslInterpolator ( std::vector< realT > & xin,
std::vector< realT > & yin )

Vector constructor.

Parameters
[in]xinthe input x data, the pointer to xin.data() is stored and xin must remain unchanged
[in]yinthe input y data, the pointer to yin.data() is stored and yin must remain unchanged

Definition at line 159 of file gslInterpolator.hpp.

References setup().

◆ ~gslInterpolator()

template<typename interpT>
mx::math::gslInterpolator< interpT >::~gslInterpolator ( )

Destructor.

Deallocates working memory.

Definition at line 165 of file gslInterpolator.hpp.

References m_acc, and m_interp.

Member Function Documentation

◆ operator()()

template<typename interpT>
interpT::realT mx::math::gslInterpolator< interpT >::operator() ( const realT & x)

Calculate the interpolated function value at a point.

Returns
the interpolated value at x
Parameters
[in]xthe point at which to interpolate

Definition at line 220 of file gslInterpolator.hpp.

References mx::liberr, m_acc, m_interp, m_xin, and m_yin.

◆ setup() [1/2]

template<typename interpT>
void mx::math::gslInterpolator< interpT >::setup ( realT * xin,
realT * yin,
size_t Nin )

Setup the interpolator for the supplied data pointers.

Exceptions
mx::err::allocerrif allocation fails
mx::err::liberrif GSL initialization fails
Parameters
[in]xinthe input x data, this pointer is stored and must remain valid
[in]yinthe input y data, this pointer is stored and must remain valid
[in]Ninthe size of data vectors

Definition at line 174 of file gslInterpolator.hpp.

References mx::allocerr, mx::liberr, m_acc, m_interp, m_xin, and m_yin.

Referenced by gslInterpolator(), gslInterpolator(), and setup().

◆ setup() [2/2]

template<typename interpT>
void mx::math::gslInterpolator< interpT >::setup ( std::vector< realT > & xin,
std::vector< realT > & yin )

Setup the interpolator for the supplied data vectors.

Exceptions
mx::err::sizeerrif the vectors are not the same size
mx::err::allocerrif allocation fails
mx::err::liberrif GSL initialization fails
Parameters
[in]xinthe input x data, the pointer to xin.data() is stored and xin must remain unchanged
[in]yinthe input y data, the pointer to yin.data() is stored and yin must remain unchanged

Definition at line 210 of file gslInterpolator.hpp.

References setup(), and mx::sizeerr.

Member Data Documentation

◆ m_acc

template<typename interpT>
gsl_interp_accel* mx::math::gslInterpolator< interpT >::m_acc { nullptr }
protected

the gsl interpolation accelerator structure

Definition at line 91 of file gslInterpolator.hpp.

Referenced by ~gslInterpolator(), operator()(), and setup().

◆ m_interp

template<typename interpT>
gsl_interp* mx::math::gslInterpolator< interpT >::m_interp { nullptr }
protected

the gsl interpolator structure

Definition at line 90 of file gslInterpolator.hpp.

Referenced by ~gslInterpolator(), operator()(), and setup().

◆ m_xin

template<typename interpT>
realT* mx::math::gslInterpolator< interpT >::m_xin
protected

the input x data

Definition at line 93 of file gslInterpolator.hpp.

Referenced by operator()(), and setup().

◆ m_yin

template<typename interpT>
realT* mx::math::gslInterpolator< interpT >::m_yin
protected

the input y data

Definition at line 94 of file gslInterpolator.hpp.

Referenced by operator()(), and setup().


The documentation for this class was generated from the following file: