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::Interp2D Class Reference

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

#include <Interp2D.H>

Public Member Functions

 Interp2D (const double *x_, const double *y_, const double *z_, const size_t nx_, const size_t ny_, const extrapType extrapXLo_=extrapError, const extrapType extrapXHi_=extrapError, const extrapType extrapYLo_=extrapError, const extrapType extrapYHi_=extrapError, const bool xLog_=false, const bool yLog_=false, const bool zLog_=false, const double zXLo_=0.0, const double zXHi_=0.0, const double zYLo_=0.0, const double zYHi_=0.0)
 Constructor.
 
 ~Interp2D ()
 Destructor.
 
double xMin () const
 Return lower limit of table in x.
 
double xMax () const
 Return upper limit of table x.
 
double yMin () const
 Return lower limit of table in y.
 
double yMax () const
 Return upper limit of table y.
 
double operator() (const Real &x_, const Real &y_) const
 Caclulate an interpolated value from the table.
 

Private Attributes

const double * x
 
const double * y
 
const double * z
 
const size_t nx
 
const size_t ny
 
const extrapType extrapXLo
 
const extrapType extrapXHi
 
const extrapType extrapYLo
 
const extrapType extrapYHi
 
const bool xLog
 
const bool yLog
 
const bool zLog
 
const double zXLo
 
const double zXHi
 
const double zYLo
 
const double zYHi
 
gsl_interp2d * interp
 
ThreadVec< gsl_interp_accel * > accX
 
ThreadVec< gsl_interp_accel * > accY
 

Static Private Attributes

static constexpr double tol = 1.0e-8
 

Detailed Description

A class to handle interpolation on 2D tables.

This class wraps the GSL interpolation routines and provides interpolation on 2D 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

◆ Interp2D()

criptic::Interp2D::Interp2D ( const double *  x_,
const double *  y_,
const double *  z_,
const size_t  nx_,
const size_t  ny_,
const extrapType  extrapXLo_ = extrapError,
const extrapType  extrapXHi_ = extrapError,
const extrapType  extrapYLo_ = extrapError,
const extrapType  extrapYHi_ = extrapError,
const bool  xLog_ = false,
const bool  yLog_ = false,
const bool  zLog_ = false,
const double  zXLo_ = 0.0,
const double  zXHi_ = 0.0,
const double  zYLo_ = 0.0,
const double  zYHi_ = 0.0 
)
inline

Constructor.

Parameters
x_Tabular data in the first independent variable
y_Tabular data in the second independent variable
z_Tabular data for the dependent variable
nx_Number of entries in table in x direction
ny_Number of entries in table in y direction
extrapXLo_Type of extrapolation to use in low x direction
extrapXHi_Type of extrapolation to use in high x direction
extrapYLo_Type of extrapolation to use in low y direction
extrapYHi_Type of extrapolation to use in high y direction
xLog_If true, the values in x are log_10(x)
yLog_If true, the values in y are log_10(y)
zLog_If true, the values in z are log_10(z)
zXLo_Value for off-table low extrapolation in x
zXHi_Value for off-table high extrapolation in x
zYLo_Value for off-table low extrapolation in x
zYHi_Value for off-table high extrapolation in x

This class does not make any copies of the underlying data pointed to by x_, y_, or z_, so it is the responsibility of the user not to modify or deallocate them. The parameters zXLo_ and zXHi_ are only used if extrapXLo_ or extrapXHi_ is set to extrapFixedVal, in which case they specify the fixed value that is returned; the same applies to zYLo_ and zYHi_.

◆ ~Interp2D()

criptic::Interp2D::~Interp2D ( )
inline

Destructor.

Member Function Documentation

◆ operator()()

criptic::Interp2D::operator() ( const Real x_,
const Real y_ 
) const
inline

Caclulate an interpolated value from the table.

Parameters
x_The x value to which to interpolate
y_The y value to which to interpolate
Returns
The interpolated value at (x_, y_)

◆ xMax()

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

Return upper limit of table x.

Returns
Maximum value of x in table

◆ xMin()

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

Return lower limit of table in x.

Returns
Minimum value of x in table

◆ yMax()

double criptic::Interp2D::yMax ( ) const
inline

Return upper limit of table y.

Returns
Maximum value of y in table

◆ yMin()

double criptic::Interp2D::yMin ( ) const
inline

Return lower limit of table in y.

Returns
Minimum value of y in table

Member Data Documentation

◆ accX

ThreadVec<gsl_interp_accel *> criptic::Interp2D::accX
private

GSL accelerator for x

◆ accY

ThreadVec<gsl_interp_accel *> criptic::Interp2D::accY
private

GSL accelerator for y

◆ extrapXHi

const extrapType criptic::Interp2D::extrapXHi
private

Extrapolation type in high x direction

◆ extrapXLo

const extrapType criptic::Interp2D::extrapXLo
private

Extrapolation type in low x direction

◆ extrapYHi

const extrapType criptic::Interp2D::extrapYHi
private

Extrapolation type in high y direction

◆ extrapYLo

const extrapType criptic::Interp2D::extrapYLo
private

Extrapolation type in low y direction

◆ interp

gsl_interp2d* criptic::Interp2D::interp
private

GSL interpolator

◆ nx

const size_t criptic::Interp2D::nx
private

Number of entries in table in x direction

◆ ny

const size_t criptic::Interp2D::ny
private

Number of entries in table in y direction

◆ tol

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

Tolerance for off-table values

◆ x

const double* criptic::Interp2D::x
private

x values in table

◆ xLog

const bool criptic::Interp2D::xLog
private

Are the x values logarithmic?

◆ y

const double* criptic::Interp2D::y
private

y values in table

◆ yLog

const bool criptic::Interp2D::yLog
private

Are the y values logarithmic?

◆ z

const double* criptic::Interp2D::z
private

z values in table

◆ zLog

const bool criptic::Interp2D::zLog
private

Are the z values logarithmic?

◆ zXHi

const double criptic::Interp2D::zXHi
private

Off-table high x value

◆ zXLo

const double criptic::Interp2D::zXLo
private

Off-table low x value

◆ zYHi

const double criptic::Interp2D::zYHi
private

Off-table high y value

◆ zYLo

const double criptic::Interp2D::zYLo
private

Off-table low y value


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