OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
AbstractSpline Class Referenceabstract

Base class for the linear and cubic interpolation spline classes. More...

#include <AbstractSpline.h>

Inheritance diagram for AbstractSpline:
Inheritance graph
Collaboration diagram for AbstractSpline:
Collaboration graph

Classes

class  Accelerator
 Accelerator caching last interval indices. More...
 

Public Member Functions

 AbstractSpline ()=default
 Default constructor.
 
virtual ~AbstractSpline ()=default
 Polymorphic destructor.
 
virtual void init (const std::vector< double > &x, const std::vector< double > &y)
 Initialize from tabulated data (natural spline).
 
virtual double eval (double x, Accelerator &accel) const =0
 Evaluate the spline at x using an accelerator.
 
virtual double evalIntegral (double xa, double xb, Accelerator &accel) const =0
 Evaluate the integral of the spline at x.
 

Protected Member Functions

size_t findInterval (double x, size_t &intervalCache) const
 Return the interval index for the given x-coordinate, using the supplied cached value if possible.
 

Protected Attributes

std::vector< double > x_ {}
 
std::vector< double > y_ {}
 

Detailed Description

Base class for the linear and cubic interpolation spline classes.

Definition at line 25 of file AbstractSpline.h.

Constructor & Destructor Documentation

◆ AbstractSpline()

AbstractSpline::AbstractSpline ( )
default

Default constructor.

◆ ~AbstractSpline()

virtual AbstractSpline::~AbstractSpline ( )
virtualdefault

Polymorphic destructor.

Member Function Documentation

◆ eval()

virtual double AbstractSpline::eval ( double  x,
Accelerator accel 
) const
pure virtual

Evaluate the spline at x using an accelerator.

Parameters
xInput: x-coordinate.
accelInput/Output: cached interval index.
Returns
Output: interpolated value.

Implemented in CubicSpline, and LinearSpline.

Referenced by gsl_spline_eval().

◆ evalIntegral()

virtual double AbstractSpline::evalIntegral ( double  xa,
double  xb,
Accelerator accel 
) const
pure virtual

Evaluate the integral of the spline at x.

Parameters
xaInput: x-coordinate lower bound.
xbInput: x-coordinate upper bound.
accelInput/output: accelerator for interval caching.
Returns
Output: interpolated integral value (with linear extrapolation).

Implemented in CubicSpline, and LinearSpline.

Referenced by gsl_spline_eval_integ().

◆ findInterval()

size_t AbstractSpline::findInterval ( double  x,
size_t &  intervalCache 
) const
protected

Return the interval index for the given x-coordinate, using the supplied cached value if possible.

Parameters
xInput: x-coordinate.
intervalCacheInput/output: The cached interval index.
Returns
Output: The index of the interval containing x.

Definition at line 39 of file AbstractSpline.cpp.

References x_.

Referenced by CubicSpline::eval(), LinearSpline::eval(), CubicSpline::evalIntegral(), and LinearSpline::evalIntegral().

◆ init()

void AbstractSpline::init ( const std::vector< double > &  x,
const std::vector< double > &  y 
)
virtual

Initialize from tabulated data (natural spline).

Parameters
xInput: strictly increasing x-coordinates.
yInput: y-values corresponding to x.

Reimplemented in CubicSpline, and LinearSpline.

Definition at line 22 of file AbstractSpline.cpp.

References x_, and y_.

Referenced by gsl_spline_init(), CubicSpline::init(), and LinearSpline::init().

Member Data Documentation

◆ x_

◆ y_


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