1D Cubic spline class accomodating several boundary condition types including not-a-knot and periodic.
Public Fields
-
Vec x
- vector of abscissae
-
Vec y
- vector of ordinates
-
bool init
- true if spline coefficients have been initialized
-
bool periodic
- true if periodic
-
Vec_int bc_type
- A 2-integer vector defining the type of boundary conditions
-
Vec bc_value
- Boundary condition values
-
double xmin
- Min of abscissae
-
double xmax
- Max of abscissae
-
double ymin
- Min of ordinates
-
double ymax
- Max of ordinates
Public Methods
-
cubspline()
- Constructor.
-
cubspline(const Vec &x1, const Vec &y1, Vec_int bc_type1=cubspline_itwo_zeros, Vec bc_value1=cubspline_two_zeros)
- Constructor.
-
cubspline(const Vec &x1, const Vec &y1, std::string per)
- Constructor for splines with periodic boundary conditions.
-
void load(const Vec &x, const Vec &y, Vec_int bc_type1, Vec bc_value1)
- Build spline object.
-
void load(const Vec &x, const Vec &y)
- Build spline object.
-
void load(const Vec &x, const Vec &y, std::string per)
- Build spline object.
-
bool is_below(Vec &xi)
- Check if xi < xmin.
-
bool is_above(Vec &xi)
- Check if xi > xmax.
-
bool is_extra(Vec &xi)
- Check if xi < xmin and xi > xmax.
-
Vec mask(const Vec &xi)
- Return 1's for all nodes xi that are inside [min(x), max(x)].
-
Vec_int bra(const Vec &xi)
- Return indices of nodes closest to the left of xi.
-
size_t bra(const double xi)
- Return index of node closest to the left of xi.
-
Vec_int near(const Vec &xi)
- Return indices of nodes nearest to xi.
-
size_t near(const double xi)
- Return index of node nearest xi.
-
Vec_int ket(const Vec &xi)
- Return indices of nodes closest to the right of xi.
-
size_t ket(const double xi)
- Return index of node closest to the right of xi.
-
Vec step(const Vec &xi)
- Step function interpolation.
-
double step(const double xi)
- Step function interpolation.
-
Vec linear(const Vec &xi)
- Linear function interpolation.
-
double linear(const double xi)
- Linear function interpolation.
-
Vec cubic(const Vec &xi)
- Cubic function interpolation.
-
double cubic(const double xi)
- Cubic function interpolation.
-
Vec prime(const Vec &xi, std::string method="cubic")
- First derivative.
-
double prime(const double xi, std::string method="cubic")
- First derivative.
-
Vec second(const Vec &xi)
- Second derivative.
-
double second(const double xi)
- Second derivative.
-
Vec third(const Vec &xi)
- Third derivative.
-
double third(const double xi)
- Third derivative.
-
Vec integrate(const Vec &xi_to)
- Integrate from xmin to xi_to.
-
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>.
Vec x
- vector of abscissae
Vec y
- vector of ordinates
bool init
- true if spline coefficients have been initialized
bool periodic
- true if periodic
Vec_int bc_type
- A 2-integer vector defining the type of boundary conditions
Vec bc_value
- Boundary condition values
double xmin
- Min of abscissae
double xmax
- Max of abscissae
double ymin
- Min of ordinates
double ymax
- Max of ordinates
cubspline()
- Constructor.
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).
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
void 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()
void 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()
void 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()
bool 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
bool 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
bool 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
Vec 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.
Vec_int bra(const Vec &xi)
- Return indices of nodes closest to the left of xi.
- Parameters:
- xi - abscissae
- Returns:
- result = node indices
size_t bra(const double xi)
- Return index of node closest to the left of xi.
- Parameters:
- xi - abscissa
- Returns:
- result = node index
Vec_int near(const Vec &xi)
- Return indices of nodes nearest to xi.
- Parameters:
- xi - abscissae
- Returns:
- result = node indices
size_t near(const double xi)
- Return index of node nearest xi.
- Parameters:
- xi - abscissa
- Returns:
- result = node index
Vec_int ket(const Vec &xi)
- Return indices of nodes closest to the right of xi.
- Parameters:
- xi - abscissae
- Returns:
- result = node indices
size_t ket(const double xi)
- Return index of node closest to the right of xi.
- Parameters:
- xi - abscissa
- Returns:
- result = node index
Vec step(const Vec &xi)
- Step function interpolation.
- Parameters:
- xi - abscissae
- Returns:
- result = piecewise constant interpolation.
double step(const double xi)
- Step function interpolation.
- Parameters:
- xi - abscissa
- Returns:
- result = piecewise constant interpolation.
Vec linear(const Vec &xi)
- Linear function interpolation.
- Parameters:
- xi - abscissae
- Returns:
- result = piecewise linear interpolation.
double linear(const double xi)
- Linear function interpolation.
- Parameters:
- xi - abscissa
- Returns:
- result = piecewise linear interpolation.
Vec cubic(const Vec &xi)
- Cubic function interpolation.
- Parameters:
- xi - abscissae
- Returns:
- result = piecewise linear interpolation.
double cubic(const double xi)
- Cubic function interpolation.
- Parameters:
- xi - abscissa
- Returns:
- result = piecewise linear interpolation.
Vec prime(const Vec &xi, std::string method="cubic")
- First derivative.
- Parameters:
- xi - abscissae
method - can be "cubic" or "linear"
- Returns:
- result = df/dx
double prime(const double xi, std::string method="cubic")
- First derivative.
- Parameters:
- xi - abscissa
method - can be "cubic" or "linear"
- Returns:
- result = df/dx
Vec second(const Vec &xi)
- Second derivative.
- Parameters:
- xi - abscissae
- Returns:
- result = d2f/dx2
double second(const double xi)
- Second derivative.
- Parameters:
- xi - abscissa
- Returns:
- result = d2f/dx2
Vec third(const Vec &xi)
- Third derivative.
- Parameters:
- xi - abscissae
- Returns:
- result = d3f/dx3
double third(const double xi)
- Third derivative.
- Parameters:
- xi - abscissa
- Returns:
- result = d3f/dx3
Vec integrate(const Vec &xi_to)
- Integrate from xmin to xi_to.
- Parameters:
- xi_to - right end point (array)
- Returns:
- integral
double 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++.