class cubspline

1D Cubic spline class accomodating several boundary condition types including not-a-knot and periodic.

Public Fields

[more]Vec x
vector of abscissae
[more]Vec y
vector of ordinates
[more]bool init
true if spline coefficients have been initialized
[more]bool periodic
true if periodic
[more]Vec_int bc_type
A 2-integer vector defining the type of boundary conditions
[more]Vec bc_value
Boundary condition values
[more]double xmin
Min of abscissae
[more]double xmax
Max of abscissae
[more]double ymin
Min of ordinates
[more]double ymax
Max of ordinates

Public Methods

[more] cubspline()
Constructor.
[more] cubspline(const Vec &x1, const Vec &y1, Vec_int bc_type1=cubspline_itwo_zeros, Vec bc_value1=cubspline_two_zeros)
Constructor.
[more] cubspline(const Vec &x1, const Vec &y1, std::string per)
Constructor for splines with periodic boundary conditions.
[more]void load(const Vec &x, const Vec &y, Vec_int bc_type1, Vec bc_value1)
Build spline object.
[more]void load(const Vec &x, const Vec &y)
Build spline object.
[more]void load(const Vec &x, const Vec &y, std::string per)
Build spline object.
[more]bool is_below(Vec &xi)
Check if xi < xmin.
[more]bool is_above(Vec &xi)
Check if xi > xmax.
[more]bool is_extra(Vec &xi)
Check if xi < xmin and xi > xmax.
[more]Vec mask(const Vec &xi)
Return 1's for all nodes xi that are inside [min(x), max(x)].
[more]Vec_int bra(const Vec &xi)
Return indices of nodes closest to the left of xi.
[more]size_t bra(const double xi)
Return index of node closest to the left of xi.
[more]Vec_int near(const Vec &xi)
Return indices of nodes nearest to xi.
[more]size_t near(const double xi)
Return index of node nearest xi.
[more]Vec_int ket(const Vec &xi)
Return indices of nodes closest to the right of xi.
[more]size_t ket(const double xi)
Return index of node closest to the right of xi.
[more]Vec step(const Vec &xi)
Step function interpolation.
[more]double step(const double xi)
Step function interpolation.
[more]Vec linear(const Vec &xi)
Linear function interpolation.
[more]double linear(const double xi)
Linear function interpolation.
[more]Vec cubic(const Vec &xi)
Cubic function interpolation.
[more]double cubic(const double xi)
Cubic function interpolation.
[more]Vec prime(const Vec &xi, std::string method="cubic")
First derivative.
[more]double prime(const double xi, std::string method="cubic")
First derivative.
[more]Vec second(const Vec &xi)
Second derivative.
[more]double second(const double xi)
Second derivative.
[more]Vec third(const Vec &xi)
Third derivative.
[more]double third(const double xi)
Third derivative.
[more]Vec integrate(const Vec &xi_to)
Integrate from xmin to xi_to.
[more]double integrate(const double xi_to)
Integrate from xmin to xi_to.


Documentation

1D Cubic spline class accomodating several boundary condition types including not-a-knot and periodic. Once cubic spline coefficients are computed using either the constructor call or 'load' method, interpolation as well as derivatives up to and including order three can be obtained either pointwise or on grids. Integration routines are also provided. All vectors Vec are Vector<double> whereas Vec_int are Vector<size_t>.
oVec x
vector of abscissae

oVec y
vector of ordinates

obool init
true if spline coefficients have been initialized

obool periodic
true if periodic

oVec_int bc_type
A 2-integer vector defining the type of boundary conditions

oVec bc_value
Boundary condition values

odouble xmin
Min of abscissae

odouble xmax
Max of abscissae

odouble ymin
Min of ordinates

odouble ymax
Max of ordinates

o cubspline()
Constructor.

o cubspline(const Vec &x1, const Vec &y1, Vec_int bc_type1=cubspline_itwo_zeros, Vec bc_value1=cubspline_two_zeros)
Constructor. Build object given a set of (x, y) coordinates and some boundary condition constraints.

Parameters:
x1 - original abscissae
y1 - original ordinates
bc_type1 - Boundary condition types: 0 for not a knot, 1 for setting the derivative, 2 for imposing the second derivative.
bc_value1 - Values of the boundary conditions (not used for not-a-knot).

o cubspline(const Vec &x1, const Vec &y1, std::string per)
Constructor for splines with periodic boundary conditions.
Parameters:
x1 - original abscissae
y1 - original ordinates
per - if ="periodic" then periodic boundary conditions

ovoid load(const Vec &x, const Vec &y, Vec_int bc_type1, Vec bc_value1)
Build spline object.
Parameters:
- x original abscissae
- y original ordinates
bc_type1 - Boundary condition types: 0 for not a knot, 1 for setting the derivative, 2 for imposing the second derivative.
See Also:
cubspline()

ovoid load(const Vec &x, const Vec &y)
Build spline object. Not-a-knot boundary conditions.
Parameters:
- x original abscissae
- y original ordinates
bc_type1 - Boundary condition types: 0 for not a knot, 1 for setting the derivative, 2 for imposing the second derivative.
See Also:
cubspline()

ovoid load(const Vec &x, const Vec &y, std::string per)
Build spline object. Periodic boundary conditions.
Parameters:
- x original abscissae
- y original ordinates
bc_type1 - Boundary condition types: 0 for not a knot, 1 for setting the derivative, 2 for imposing the second derivative.
See Also:
cubspline()

obool is_below(Vec &xi)
Check if xi < xmin. Look for nodes below interval.
Parameters:
xi - grid
Returns:
true if there is a node such that xi < xmin

obool is_above(Vec &xi)
Check if xi > xmax. Look for nodes above interval.
Parameters:
xi - grid
Returns:
true if there is a node such that xi > xmax

obool is_extra(Vec &xi)
Check if xi < xmin and xi > xmax. Look for nodes outside interval.
Parameters:
xi - grid
Returns:
true if there is a node such that xi > xmax and xi < xmin

oVec mask(const Vec &xi)
Return 1's for all nodes xi that are inside [min(x), max(x)].
Parameters:
xi - grid
Returns:
vector 0's for nodes outside [xmin, xmax], resp 1's for nodes inside.

oVec_int bra(const Vec &xi)
Return indices of nodes closest to the left of xi.
Parameters:
xi - abscissae
Returns:
result = node indices

osize_t bra(const double xi)
Return index of node closest to the left of xi.
Parameters:
xi - abscissa
Returns:
result = node index

oVec_int near(const Vec &xi)
Return indices of nodes nearest to xi.
Parameters:
xi - abscissae
Returns:
result = node indices

osize_t near(const double xi)
Return index of node nearest xi.
Parameters:
xi - abscissa
Returns:
result = node index

oVec_int ket(const Vec &xi)
Return indices of nodes closest to the right of xi.
Parameters:
xi - abscissae
Returns:
result = node indices

osize_t ket(const double xi)
Return index of node closest to the right of xi.
Parameters:
xi - abscissa
Returns:
result = node index

oVec step(const Vec &xi)
Step function interpolation.
Parameters:
xi - abscissae
Returns:
result = piecewise constant interpolation.

odouble step(const double xi)
Step function interpolation.
Parameters:
xi - abscissa
Returns:
result = piecewise constant interpolation.

oVec linear(const Vec &xi)
Linear function interpolation.
Parameters:
xi - abscissae
Returns:
result = piecewise linear interpolation.

odouble linear(const double xi)
Linear function interpolation.
Parameters:
xi - abscissa
Returns:
result = piecewise linear interpolation.

oVec cubic(const Vec &xi)
Cubic function interpolation.
Parameters:
xi - abscissae
Returns:
result = piecewise linear interpolation.

odouble cubic(const double xi)
Cubic function interpolation.
Parameters:
xi - abscissa
Returns:
result = piecewise linear interpolation.

oVec prime(const Vec &xi, std::string method="cubic")
First derivative.
Parameters:
xi - abscissae
method - can be "cubic" or "linear"
Returns:
result = df/dx

odouble prime(const double xi, std::string method="cubic")
First derivative.
Parameters:
xi - abscissa
method - can be "cubic" or "linear"
Returns:
result = df/dx

oVec second(const Vec &xi)
Second derivative.
Parameters:
xi - abscissae
Returns:
result = d2f/dx2

odouble second(const double xi)
Second derivative.
Parameters:
xi - abscissa
Returns:
result = d2f/dx2

oVec third(const Vec &xi)
Third derivative.
Parameters:
xi - abscissae
Returns:
result = d3f/dx3

odouble third(const double xi)
Third derivative.
Parameters:
xi - abscissa
Returns:
result = d3f/dx3

oVec integrate(const Vec &xi_to)
Integrate from xmin to xi_to.
Parameters:
xi_to - right end point (array)
Returns:
integral

odouble integrate(const double xi_to)
Integrate from xmin to xi_to.
Parameters:
xi_to - right end point
Returns:
integral


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.