npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
npstat::LinInterpolatedTable1D Class Reference

#include <LinInterpolatedTable1D.hh>

Public Member Functions

template<typename Real >
 LinInterpolatedTable1D (const Real *data, unsigned npoints, double x_min, double x_max, bool leftExtrapolationLinear, bool rightExtrapolationLinear)
 
template<typename Real >
 LinInterpolatedTable1D (const std::vector< std::pair< Real, Real > > &v, unsigned npoints, bool leftExtrapolationLinear, bool rightExtrapolationLinear)
 
 LinInterpolatedTable1D (double c)
 
 LinInterpolatedTable1D ()
 
double operator() (const double &x) const
 
bool operator== (const LinInterpolatedTable1D &r) const
 
bool operator!= (const LinInterpolatedTable1D &r) const
 
double xmin () const
 
double xmax () const
 
unsigned npoints () const
 
bool leftExtrapolationLinear () const
 
bool rightExtrapolationLinear () const
 
const double * data () const
 
bool isMonotonous () const
 
CPP11_auto_ptr< LinInterpolatedTable1Dinverse (unsigned npoints, bool leftExtrapolationLinear, bool rightExtrapolationLinear) const
 
gs::ClassId classId () const
 
bool write (std::ostream &of) const
 

Static Public Member Functions

static const char * classname ()
 
static unsigned version ()
 
static LinInterpolatedTable1Dread (const gs::ClassId &id, std::istream &)
 

Detailed Description

This class can be used to interpolate a table of values linearly in one dimension. Regular coordinate spacing only, double precision numbers are used to represent the data internally. Extrapolation beyond the leftmost or rightmost data points could be either linear or constant.

Constructor & Destructor Documentation

◆ LinInterpolatedTable1D() [1/4]

template<typename Real >
npstat::LinInterpolatedTable1D::LinInterpolatedTable1D ( const Real *  data,
unsigned  npoints,
double  x_min,
double  x_max,
bool  leftExtrapolationLinear,
bool  rightExtrapolationLinear 
)

Constructor from a regularly spaced data. Extrapolation from the edge to infinity can be either linear or constant, as defined by the parameters "leftExtrapolationLinear" and "rightExtrapolationLinear". "npoints" (size of the data array) must be larger than 1.

◆ LinInterpolatedTable1D() [2/4]

template<typename Real >
npstat::LinInterpolatedTable1D::LinInterpolatedTable1D ( const std::vector< std::pair< Real, Real > > &  v,
unsigned  npoints,
bool  leftExtrapolationLinear,
bool  rightExtrapolationLinear 
)

Constructor from a list of points, not necessarily regularly spaced (but must be sorted in the increasing order). The first member of the pair is the x coordinate, the second is the tabulated function value. The input list will be interpolated to "npoints" internal points linearly.

◆ LinInterpolatedTable1D() [3/4]

npstat::LinInterpolatedTable1D::LinInterpolatedTable1D ( double  c)
explicit

Constructor which builds a function returning the given constant for every argument value

◆ LinInterpolatedTable1D() [4/4]

npstat::LinInterpolatedTable1D::LinInterpolatedTable1D ( )

Default constructor builds a functor which always returns 0.0

Member Function Documentation

◆ classId()

gs::ClassId npstat::LinInterpolatedTable1D::classId ( ) const
inline

Method related to "geners" I/O

◆ inverse()

CPP11_auto_ptr<LinInterpolatedTable1D> npstat::LinInterpolatedTable1D::inverse ( unsigned  npoints,
bool  leftExtrapolationLinear,
bool  rightExtrapolationLinear 
) const

Generate the inverse lookup table. Note that it is only possible if the original table is monotonous (not taking into account possible flat regions at the edges). If the inversion is not possible, NULL pointer will be returned.

The new table will have "npoints" points. The parameters "leftExtrapolationLinear" and "rightExtrapolationLinear" refer to the inverted table. Note that left and right will exchange places if the original table is decreasing.

◆ isMonotonous()

bool npstat::LinInterpolatedTable1D::isMonotonous ( ) const

This method checks whether the table is monotonous (and, therefore, can be inverted). Possible flat regions at the edges are not taken into account.

◆ operator()()

double npstat::LinInterpolatedTable1D::operator() ( const double &  x) const

Interpolate to the given coordinate

◆ operator==()

bool npstat::LinInterpolatedTable1D::operator== ( const LinInterpolatedTable1D r) const

Comparison for equality (useful for I/O testing)

◆ xmin()

double npstat::LinInterpolatedTable1D::xmin ( ) const
inline

A simple inspector


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