A cubic spline class. More...
#include <cubicspline.h>


Public Member Functions | |
| CubicSpline ()=default | |
| ~CubicSpline () override=default | |
| void | Interpolate (const Eigen::VectorXd &x, const Eigen::VectorXd &y) override |
| Calculate interpolating spline for given (x,y) values. Points on resulting spline can be obtained via Calculate(). | |
| void | Fit (const Eigen::VectorXd &x, const Eigen::VectorXd &y) override |
| Fit spline through noisy (x,y) values. Points on resulting fitted spline can be obtained via Calculate(). | |
| double | Calculate (double r) override |
| Calculate spline function value for a given x value on the spline created by Interpolate() or Fit() | |
| double | CalculateDerivative (double r) override |
| Calculate y value for a given x value on the derivative of the spline created by function Interpolate or Fit. | |
| void | setSplineData (const Eigen::VectorXd &f, const Eigen::VectorXd &f2) |
| template<typename matrix_type> | |
| void | AddToFitMatrix (matrix_type &M, double x, Index offset1, Index offset2=0, double scale=1) |
| Add a point (one entry) to fitting matrix. | |
| template<typename matrix_type> | |
| void | AddToFitMatrix (matrix_type &M, double x, Index offset1, Index offset2, double scale1, double scale2) |
| Add a point (one entry) to fitting matrix. | |
| template<typename matrix_type, typename vector_type> | |
| void | AddToFitMatrix (matrix_type &M, vector_type &x, Index offset1, Index offset2=0) |
| Add a vector of points to fitting matrix. | |
| template<typename matrix_type> | |
| void | AddBCSumZeroToFitMatrix (matrix_type &M, Index offset1, Index offset2=0) |
| Add boundary condition of sum_i f_i =0 to fitting matrix. | |
| template<typename matrix_type> | |
| void | AddBCToFitMatrix (matrix_type &M, Index offset1, Index offset2=0) |
| Add boundary conditions to fitting matrix. | |
| Eigen::VectorXd | Calculate (const Eigen::VectorXd &x) |
| Calculate spline function values for given x values on the spline created by Interpolate() or Fit() | |
| Eigen::VectorXd | CalculateDerivative (const Eigen::VectorXd &x) |
| Calculate y values for given x values on the derivative of the spline created by function Interpolate or Fit. | |
Public Member Functions inherited from votca::tools::Spline | |
| Spline ()=default | |
| virtual | ~Spline ()=default |
| void | setBC (eBoundary bc) |
| Set the boundary type of the spline. | |
| void | setBCInt (Index bc) |
| Set the boundary type of the spline. | |
| double | getGridPoint (int i) |
| Get the grid point of certain index. | |
| Eigen::VectorXd | Calculate (const Eigen::VectorXd &x) |
| Calculate spline function values for given x values on the spline created by Interpolate() or Fit() | |
| Eigen::VectorXd | CalculateDerivative (const Eigen::VectorXd &x) |
| Calculate y values for given x values on the derivative of the spline created by function Interpolate or Fit. | |
| void | Print (std::ostream &out, double interval) |
| Print spline values (using Calculate()) on output "out" on the entire grid in steps of "interval". | |
| Index | getInterval (double r) |
| Determine the index of the interval containing value r. | |
| Index | GenerateGrid (double min, double max, double h) |
| Generate the grid for fitting from "min" to "max" in steps of "h". | |
| Eigen::VectorXd & | getX () |
| Get the grid array x. | |
| const Eigen::VectorXd & | getX () const |
Private Member Functions | |
| double | A (double r) |
| double | B (double r) |
| double | C (double r) |
| double | D (double r) |
| double | Aprime (double r) |
| double | Bprime (double r) |
| double | Cprime (double r) |
| double | Dprime (double r) |
| double | A_prime_l (Index i) |
| double | A_prime_r (Index i) |
| double | B_prime_l (Index i) |
| double | B_prime_r (Index i) |
| double | C_prime_l (Index i) |
| double | C_prime_r (Index i) |
| double | D_prime_l (Index i) |
| double | D_prime_r (Index i) |
Private Attributes | |
| Eigen::VectorXd | f_ |
| Eigen::VectorXd | f2_ |
Additional Inherited Members | |
Public Types inherited from votca::tools::Spline | |
| enum | eBoundary { splineNormal = 0 , splinePeriodic = 1 , splineDerivativeZero = 2 } |
| enum for type of boundary condition More... | |
Protected Attributes inherited from votca::tools::Spline | |
| eBoundary | boundaries_ = eBoundary::splineNormal |
| Get the spline data f_. | |
| Eigen::VectorXd | r_ |
A cubic spline class.
This class does cubic piecewise spline interpolation and spline fitting. As representation of a single spline, the general form
\[ S_i(x) = A(x,h_i) f_i + B(x,h_i) f_{i+1} + C(x,h_i) f''_i + d(x,h_i) f''_{i+1} \]
with
\[ x_i \le x < x_{i+1}\,,\\ h_i = x_{i+1} - x_{i} \]
The \(f_i\,,\,,f'' i_\) are the function values and second derivates at point \(x_i\).
The parameters \(f''_i\) are no free parameters, they are determined by the smoothing condition that the first derivatives are continuous. So the only free paramers are the grid points x_i as well as the functon values f_i at these points. A spline can be generated in several ways:
Definition at line 54 of file cubicspline.h.
|
default |
|
overridedefault |
|
private |
Definition at line 141 of file cubicspline.cc.
|
private |
Definition at line 190 of file cubicspline.cc.
|
private |
Definition at line 202 of file cubicspline.cc.
|
inline |
Add boundary condition of sum_i f_i =0 to fitting matrix.
| M | pointer to matrix |
| offset1 | relative to getInterval(x) |
| offset2 | relative to getInterval(x) |
Definition at line 212 of file cubicspline.h.
|
inline |
Add boundary conditions to fitting matrix.
| M | pointer to matrix |
| offset1 | relative to getInterval(x) |
| offset2 | relative to getInterval(x) |
Definition at line 221 of file cubicspline.h.
|
inline |
Add a point (one entry) to fitting matrix.
| M | pointer to matrix [in] [out] |
| x | value [in] |
| offset1 | relative to getInterval(x) [in] |
| offset2 | relative to getInterval(x) [in] |
| scale1 | parameters for terms "A,B,C,D" [in] |
| scale2 | parameters for terms "AA,BB,CC,DD" [in] When creating a matrix to fit data with a spline, this function creates one entry in that fitting matrix. |
Definition at line 187 of file cubicspline.h.
|
inline |
Add a point (one entry) to fitting matrix.
| M | pointer to matrix |
| x | value |
| offset1 | relative to getInterval(x) |
| offset2 | relative to getInterval(x) |
| scale | parameters for terms "A,B,C,D" When creating a matrix to fit data with a spline, this function creates one entry in that fitting matrix. |
Definition at line 176 of file cubicspline.h.
|
inline |
Add a vector of points to fitting matrix.
| M | pointer to matrix |
| x | vector of x values |
| offset1 | relative to getInterval(x) |
| offset2 | relative to getInterval(x) Same as previous function, but vector-valued and with scale=1.0 |
Definition at line 200 of file cubicspline.h.
|
private |
Definition at line 146 of file cubicspline.cc.
|
private |
Definition at line 150 of file cubicspline.cc.
|
private |
Definition at line 192 of file cubicspline.cc.
|
private |
Definition at line 206 of file cubicspline.cc.
|
private |
Definition at line 155 of file cubicspline.cc.
|
private |
Definition at line 159 of file cubicspline.cc.
|
private |
Definition at line 194 of file cubicspline.cc.
|
private |
Definition at line 208 of file cubicspline.cc.
| Eigen::VectorXd votca::tools::Spline::Calculate | ( | const Eigen::VectorXd & | x | ) |
Calculate spline function values for given x values on the spline created by Interpolate() or Fit()
| x | vector of data values |
|
overridevirtual |
Calculate spline function value for a given x value on the spline created by Interpolate() or Fit()
| x | data value |
Implements votca::tools::Spline.
Definition at line 129 of file cubicspline.cc.
| Eigen::VectorXd votca::tools::Spline::CalculateDerivative | ( | const Eigen::VectorXd & | x | ) |
|
overridevirtual |
Calculate y value for a given x value on the derivative of the spline created by function Interpolate or Fit.
| x | data value |
Implements votca::tools::Spline.
Definition at line 135 of file cubicspline.cc.
|
private |
Definition at line 168 of file cubicspline.cc.
|
private |
Definition at line 175 of file cubicspline.cc.
|
private |
Definition at line 198 of file cubicspline.cc.
|
private |
Definition at line 212 of file cubicspline.cc.
|
private |
Definition at line 183 of file cubicspline.cc.
|
overridevirtual |
Fit spline through noisy (x,y) values. Points on resulting fitted spline can be obtained via Calculate().
| x | values of data to be fitted |
| y | values of data to be fitted both vectors must be of same size |
Implements votca::tools::Spline.
Definition at line 86 of file cubicspline.cc.
|
overridevirtual |
Calculate interpolating spline for given (x,y) values. Points on resulting spline can be obtained via Calculate().
| x | values of data to be interpolated |
| y | values of data to be interpolated both vectors must be of same size |
Implements votca::tools::Spline.
Definition at line 31 of file cubicspline.cc.
|
inline |
Definition at line 81 of file cubicspline.h.
|
private |
Definition at line 150 of file cubicspline.h.
|
private |
Definition at line 148 of file cubicspline.h.