This class interpolates tabulated functions with cubic splines. More...
#include <SplineInterpolation.h>
Public Member Functions | |
SplineInterpolation () | |
SplineInterpolation (const std::vector< Real > &x, const std::vector< Real > &y, Real yp1=_deriv_bound, Real ypn=_deriv_bound) | |
Construct the object. More... | |
virtual | ~SplineInterpolation ()=default |
void | setData (const std::vector< Real > &x, const std::vector< Real > &y, Real yp1=_deriv_bound, Real ypn=_deriv_bound) |
Set the x-, y- values and first derivatives. More... | |
void | errorCheck () |
Real | sample (Real x) const |
This function will take an independent variable input and will return the dependent variable based on the generated fit. More... | |
ADReal | sample (const ADReal &x) const |
Real | sampleDerivative (Real x) const |
Real | sample2ndDerivative (Real x) const |
unsigned int | getSampleSize () |
This function returns the size of the array holding the points, i.e. More... | |
Real | domain (int i) const |
Real | range (int i) const |
Real | sample (const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &y2, Real x_int) const |
ADReal | sample (const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &y2, const ADReal &x_int) const |
Real | sampleDerivative (const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &y2, Real x_int) const |
Real | sample2ndDerivative (const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &y2, Real x_int) const |
Protected Member Functions | |
void | solve () |
template<typename T > | |
T | sample (const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &y2, const T &x_int, unsigned int klo, unsigned int khi) const |
Sample value at point x_int given the indices of the vector of dependent values that bound the point. More... | |
void | spline (const std::vector< Real > &x, const std::vector< Real > &y, std::vector< Real > &y2, Real yp1=_deriv_bound, Real ypn=_deriv_bound) |
This function calculates the second derivatives based on supplied x and y-vectors. More... | |
void | findInterval (const std::vector< Real > &x, Real x_int, unsigned int &klo, unsigned int &khi) const |
template<typename T > | |
void | computeCoeffs (const std::vector< Real > &x, unsigned int klo, unsigned int khi, const T &x_int, Real &h, T &a, T &b) const |
Protected Attributes | |
std::vector< Real > | _x |
std::vector< Real > | _y |
Real | _yp1 |
boundary conditions More... | |
Real | _ypn |
std::vector< Real > | _y2 |
Second derivatives. More... | |
Static Protected Attributes | |
static int | _file_number = 0 |
static const Real | _deriv_bound = std::numeric_limits<Real>::max() |
This class interpolates tabulated functions with cubic splines.
Adopted from Numerical Recipes in C (section 3.3).
Definition at line 20 of file SplineInterpolation.h.
SplineInterpolation::SplineInterpolation | ( | ) |
Definition at line 20 of file SplineInterpolation.C.
SplineInterpolation::SplineInterpolation | ( | const std::vector< Real > & | x, |
const std::vector< Real > & | y, | ||
Real | yp1 = _deriv_bound , |
||
Real | ypn = _deriv_bound |
||
) |
Construct the object.
x | Tabulated function (x-positions) |
y | Tabulated function (y-positions) |
yp1 | First derivative of the interpolating function at point 1 |
ypn | First derivative of the interpolating function at point n |
If yp1, ypn are not specified or greater or equal that _deriv_bound, we use natural spline
Definition at line 22 of file SplineInterpolation.C.
|
virtualdefault |
|
protectedinherited |
Definition at line 85 of file SplineInterpolationBase.C.
Referenced by SplineInterpolationBase::sample(), SplineInterpolationBase::sample2ndDerivative(), and SplineInterpolationBase::sampleDerivative().
Definition at line 92 of file SplineInterpolation.C.
void SplineInterpolation::errorCheck | ( | ) |
Definition at line 47 of file SplineInterpolation.C.
Referenced by setData(), and SplineInterpolation().
|
protectedinherited |
Definition at line 65 of file SplineInterpolationBase.C.
Referenced by BicubicSplineInterpolation::constructColumnSpline(), BicubicSplineInterpolation::constructRowSpline(), SplineInterpolationBase::sample(), SplineInterpolationBase::sample2ndDerivative(), and SplineInterpolationBase::sampleDerivative().
unsigned int SplineInterpolation::getSampleSize | ( | ) |
This function returns the size of the array holding the points, i.e.
the number of sample points
Definition at line 104 of file SplineInterpolation.C.
Definition at line 98 of file SplineInterpolation.C.
|
inherited |
Definition at line 101 of file SplineInterpolationBase.C.
Referenced by BicubicSplineInterpolation::constructColumnSpline(), BicubicSplineInterpolation::constructRowSpline(), SplineInterpolationBase::sample(), sample(), BicubicSplineInterpolation::sample(), and BicubicSplineInterpolation::sampleValueAndDerivatives().
|
inherited |
Definition at line 113 of file SplineInterpolationBase.C.
This function will take an independent variable input and will return the dependent variable based on the generated fit.
Definition at line 68 of file SplineInterpolation.C.
Referenced by SplineFunction::value().
Definition at line 74 of file SplineInterpolation.C.
|
protectedinherited |
Sample value at point x_int given the indices of the vector of dependent values that bound the point.
This method is useful in bicubic spline interpolation, where several spline evaluations are needed to sample from a 2D point.
Definition at line 157 of file SplineInterpolationBase.C.
|
inherited |
Definition at line 141 of file SplineInterpolationBase.C.
Referenced by sample2ndDerivative(), and BicubicSplineInterpolation::sample2ndDerivative().
Definition at line 86 of file SplineInterpolation.C.
Referenced by SplineFunction::secondDerivative().
|
inherited |
Definition at line 125 of file SplineInterpolationBase.C.
Referenced by sampleDerivative(), BicubicSplineInterpolation::sampleDerivative(), and BicubicSplineInterpolation::sampleValueAndDerivatives().
Definition at line 80 of file SplineInterpolation.C.
Referenced by SplineFunction::derivative().
void SplineInterpolation::setData | ( | const std::vector< Real > & | x, |
const std::vector< Real > & | y, | ||
Real | yp1 = _deriv_bound , |
||
Real | ypn = _deriv_bound |
||
) |
|
protected |
Definition at line 62 of file SplineInterpolation.C.
Referenced by setData(), and SplineInterpolation().
|
protectedinherited |
This function calculates the second derivatives based on supplied x and y-vectors.
Definition at line 19 of file SplineInterpolationBase.C.
Referenced by BicubicSplineInterpolation::constructColumnSpline(), BicubicSplineInterpolation::constructColumnSplineSecondDerivativeTable(), BicubicSplineInterpolation::constructRowSpline(), BicubicSplineInterpolation::constructRowSplineSecondDerivativeTable(), and solve().
|
staticprotectedinherited |
Definition at line 79 of file SplineInterpolationBase.h.
Referenced by BicubicSplineInterpolation::errorCheck().
|
staticprotected |
Definition at line 80 of file SplineInterpolation.h.
|
protected |
Definition at line 71 of file SplineInterpolation.h.
Referenced by domain(), errorCheck(), getSampleSize(), sample(), sample2ndDerivative(), sampleDerivative(), setData(), and solve().
|
protected |
Definition at line 72 of file SplineInterpolation.h.
Referenced by errorCheck(), range(), sample(), sample2ndDerivative(), sampleDerivative(), setData(), and solve().
|
protected |
Second derivatives.
Definition at line 76 of file SplineInterpolation.h.
Referenced by sample(), sample2ndDerivative(), sampleDerivative(), and solve().
|
protected |
boundary conditions
Definition at line 74 of file SplineInterpolation.h.
|
protected |
Definition at line 74 of file SplineInterpolation.h.