criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
criptic::Interp1D Class Reference

A class to handle interpolation on 1D tables. More...

#include <Interp1D.H>

Public Member Functions

 Interp1D (const double *x_, const double *y_, const size_t n_, const extrapType extrapLo_=extrapError, const extrapType extrapHi_=extrapError, const bool xLog_=false, const bool yLog_=false, const double yLo_=0.0, const double yHi_=0.0)
 Constructor.
 
 ~Interp1D ()
 Destructor.
 
double xMin () const
 Return lower limit of table.
 
double xMax () const
 Return upper limit of table.
 
double operator() (const Real &x_) const
 Caclulate an interpolated value from the table.
 

Private Attributes

const double * x
 
const double * y
 
const size_t n
 
const extrapType extrapLo
 
const extrapType extrapHi
 
const bool xLog
 
const bool yLog
 
const double yLo
 
const double yHi
 
double mLo
 
double mHi
 
gsl_interp * interp
 
ThreadVec< gsl_interp_accel * > acc
 

Static Private Attributes

static constexpr double tol = 1.0e-8
 

Detailed Description

A class to handle interpolation on 1D tables.

This class wraps the GSL interpolation routines and provides interpolation on 1D tables. It automatically handles things like take logarithms when the tables are logarithmic, extrapolating where necessary, etc. Note that, because this is intended to wrap the GSL, all Real numbers here are double precision, even if the rest of the code operates in single precision.

Constructor & Destructor Documentation

◆ Interp1D()

criptic::Interp1D::Interp1D ( const double *  x_,
const double *  y_,
const size_t  n_,
const extrapType  extrapLo_ = extrapError,
const extrapType  extrapHi_ = extrapError,
const bool  xLog_ = false,
const bool  yLog_ = false,
const double  yLo_ = 0.0,
const double  yHi_ = 0.0 
)
inline

Constructor.

Parameters
x_Tabular data in the independent variable
y_Tabular data in the dependent variable
n_Number of entries in table
extrapLo_Type of extrapolation to use in low direction
extrapHi_Type of extrapolation to use in high direction
xLog_If true, the values in x are log_10(x)
yLog_If true, the values in y are log_10(y)
yLo_Value for off-table low extrapolation
yHi_Value for off-table high extrapolation

This class does not make any copies of the underlying data pointed to by x_ or y_, so it is the responsibility of the user not to modify or deallocate them. The parameters yLo_ and yHi_ are only used if extrapLo_ or extrapHi_ is set to extrapFixedVal, in which case they specify the fixed value that is returned.

◆ ~Interp1D()

criptic::Interp1D::~Interp1D ( )
inline

Destructor.

Member Function Documentation

◆ operator()()

criptic::Interp1D::operator() ( const Real x_) const
inline

Caclulate an interpolated value from the table.

Parameters
x_The value to which to interpolate
Returns
Interpolated value at x_

◆ xMax()

double criptic::Interp1D::xMax ( ) const
inline

Return upper limit of table.

Returns
Maximum value of x in table

◆ xMin()

double criptic::Interp1D::xMin ( ) const
inline

Return lower limit of table.

Returns
Minimum value of x in table

Member Data Documentation

◆ acc

ThreadVec<gsl_interp_accel *> criptic::Interp1D::acc
private

GSL accelerator

◆ extrapHi

const extrapType criptic::Interp1D::extrapHi
private

Type of extrapolation in high direction

◆ extrapLo

const extrapType criptic::Interp1D::extrapLo
private

Type of extrapolation in low direction

◆ interp

gsl_interp* criptic::Interp1D::interp
private

GSL interpolator

◆ mHi

double criptic::Interp1D::mHi
private

Slope for extrapolation in high direction

◆ mLo

double criptic::Interp1D::mLo
private

Slope for extrapolation in low direction

◆ n

const size_t criptic::Interp1D::n
private

Number of entries in table

◆ tol

constexpr double criptic::Interp1D::tol = 1.0e-8
staticconstexprprivate

Tolerance for off-table values

◆ x

const double* criptic::Interp1D::x
private

x values in table

◆ xLog

const bool criptic::Interp1D::xLog
private

Are the x values logarithmic?

◆ y

const double* criptic::Interp1D::y
private

y values in table

◆ yHi

const double criptic::Interp1D::yHi
private

Off-table high value

◆ yLo

const double criptic::Interp1D::yLo
private

Off-table low value

◆ yLog

const bool criptic::Interp1D::yLog
private

Are the y values logarithmic?


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