mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
mx::math::logInterpolator< realT > Class Template Reference

template<typename realT>
class mx::math::logInterpolator< realT >

Interpolate a function in log space.

Given a discrete function, conduct linear interpolation in log space. The input vectors are converted to their log10 values. Linear interpolation using gslInterpolator is conducted on the log10 of the input value. The output is converted back. So the result is

y = pow(10, interp(log10(x))).

Definition at line 49 of file logInterpolator.hpp.

#include <math/logInterpolator.hpp>

Public Member Functions

 logInterpolator ()
 Default constructor. More...
 
 logInterpolator (const std::vector< realT > &x, const std::vector< realT > &y)
 Convert the inputs to their log10 values, and construct the interpolator. More...
 
void setup (const std::vector< realT > &x, const std::vector< realT > &y)
 Convert the inputs to their log10 values, and construct the interpolator. More...
 
realT operator() (const realT &x)
 Calculate the interpolated value at the input. More...
 

Protected Attributes

gslInterpolator< gsl_interp_linear< realT > > m_interp
 The interpolator. More...
 
std::vector< realT > m_logx
 Internal storage of the log10 values of the x values. More...
 
std::vector< realT > m_logy
 Internal storage of the lgo10 values of the y values. More...
 

Constructor & Destructor Documentation

◆ logInterpolator() [1/2]

template<typename realT >
mx::math::logInterpolator< realT >::logInterpolator ( )
inline

Default constructor.

Definition at line 60 of file logInterpolator.hpp.

◆ logInterpolator() [2/2]

template<typename realT >
mx::math::logInterpolator< realT >::logInterpolator ( const std::vector< realT > &  x,
const std::vector< realT > &  y 
)
inline

Convert the inputs to their log10 values, and construct the interpolator.

Exceptions
mxExceptionif vectors are not the same size.
Parameters
[in]ythe input x-axis [in] the input y-axis

Definition at line 66 of file logInterpolator.hpp.

References mx::math::logInterpolator< realT >::setup().

Member Function Documentation

◆ operator()()

template<typename realT >
realT mx::math::logInterpolator< realT >::operator() ( const realT &  x)
inline

Calculate the interpolated value at the input.

x.
Returns
the interpolated value

Definition at line 115 of file logInterpolator.hpp.

References mx::math::logInterpolator< realT >::m_interp.

◆ setup()

template<typename realT >
void mx::math::logInterpolator< realT >::setup ( const std::vector< realT > &  x,
const std::vector< realT > &  y 
)
inline

Convert the inputs to their log10 values, and construct the interpolator.

Exceptions
mx::err::sizeerrif vectors are not the same size.
mx::err::invalidargif any of the values are <= 0
Parameters
[in]ythe input x-axis [in] the input y-axis

Definition at line 78 of file logInterpolator.hpp.

References mx::math::logInterpolator< realT >::m_interp, mx::math::logInterpolator< realT >::m_logx, and mx::math::logInterpolator< realT >::m_logy.

Referenced by mx::math::logInterpolator< realT >::logInterpolator().

Member Data Documentation

◆ m_interp

template<typename realT >
gslInterpolator<gsl_interp_linear<realT> > mx::math::logInterpolator< realT >::m_interp
protected

◆ m_logx

template<typename realT >
std::vector<realT> mx::math::logInterpolator< realT >::m_logx
protected

Internal storage of the log10 values of the x values.

Definition at line 55 of file logInterpolator.hpp.

Referenced by mx::math::logInterpolator< realT >::setup().

◆ m_logy

template<typename realT >
std::vector<realT> mx::math::logInterpolator< realT >::m_logy
protected

Internal storage of the lgo10 values of the y values.

Definition at line 56 of file logInterpolator.hpp.

Referenced by mx::math::logInterpolator< realT >::setup().


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