![]() |
QMCPACK
|
Perform One-Dimensional Cubic Spline Interpolation using M-relation. More...
Public Member Functions | |
CubicSplineEvaluator (T dist, T dL) | |
template<typename T1 > | |
T1 | cubicInterpolate (T1 y1, T1 y2, T1 d2y1, T1 d2y2) const |
template<typename T1 > | |
T1 | cubicInterpolateSecondDeriv (T1 y1, T1 y2, T1 d2y1, T1 d2y2, T1 &du, T1 &d2u) const |
Private Attributes | |
T | dist |
T | dL |
T | dLinv |
T | cL |
T | cR |
T | h6 |
T | q1 |
T | q2 |
T | dq1 |
T | dq2 |
Perform One-Dimensional Cubic Spline Interpolation using M-relation.
Given a function evaluated on a grid such that
we would like to interpolate for a point
in the interval
The linear interpolation formula
where
Satisfies the conditions at the endpoints but suffers from some major drawbacks. The problem with this approach is that over the range of the function
we have a series of piecewise linear equations with a zero second derivative within each interval and an undefined or infinite second derivative at the interval boundaries, the grid points
Ideally we would like to construct an interpolation function with a smooth first derivative and a continuous second derivative both within the intervals and at the the grid points.
By adding a cubic polynomial to the linear interpolation equation within each interval, we can construct an interpolation function that varies linearly in the second derivative. Assume for a moment that we have the values of the second derivative evaluated at each grid point, Now we can construct a cubic polynomial that has the correct second derivatives
at the endpoints and also evaluates to zero at the endpoints. The reason the polynomial must be zero at the endpoints is to not spoil the agreement that is already built into the linear function. A function constructed from these principals is given by the equation
where
To explicitly check that this function does indeed satisfy the conditions at the endpoints take the derivatives
and
The second derivative is continuous across the boundary between two intervals, e.g. and
and obeys the conditions at the endpoints since at
and at
We had made the assumption that the values of the second derivative are known at the grid points, which they are not. By imposing the condition that the first derivative is smooth and continuous across the boundary between two intervals it is possible to derive a set of equations to generate the 's. Evaluate the equation for the first derivative at
in the inverval
and set it equal to the same equation evaluated at
in the inverval
rearranging the terms
where To generate a unique solution for the system of
equations we have to impose boundary conditions at
the possibilities being either to set
to zero, the natural cubic spline, or, if you want to make the first derivative at the boundaries to have a specified value, use
to calculate the second derivatives at the endpoints using equation.
Definition at line 110 of file OneDimCubicSpline.h.
|
inline |
Definition at line 125 of file OneDimCubicSpline.h.
References CubicSplineEvaluator< T >::cL, CubicSplineEvaluator< T >::cR, CubicSplineEvaluator< T >::dist, CubicSplineEvaluator< T >::dL, CubicSplineEvaluator< T >::dLinv, CubicSplineEvaluator< T >::dq1, CubicSplineEvaluator< T >::dq2, CubicSplineEvaluator< T >::h6, CubicSplineEvaluator< T >::q1, and CubicSplineEvaluator< T >::q2.
|
inline |
Definition at line 138 of file OneDimCubicSpline.h.
References CubicSplineEvaluator< T >::cL, CubicSplineEvaluator< T >::cR, CubicSplineEvaluator< T >::q1, and CubicSplineEvaluator< T >::q2.
Referenced by OneDimCubicSplineLinearGrid< T >::splint(), and OneDimCubicSpline< T >::splint().
|
inline |
Definition at line 144 of file OneDimCubicSpline.h.
References CubicSplineEvaluator< T >::cL, CubicSplineEvaluator< T >::cR, CubicSplineEvaluator< T >::dLinv, CubicSplineEvaluator< T >::dq1, CubicSplineEvaluator< T >::dq2, CubicSplineEvaluator< T >::q1, and CubicSplineEvaluator< T >::q2.
Referenced by OneDimCubicSpline< T >::splint().
|
private |
Definition at line 116 of file OneDimCubicSpline.h.
Referenced by CubicSplineEvaluator< T >::cubicInterpolate(), CubicSplineEvaluator< T >::cubicInterpolateSecondDeriv(), and CubicSplineEvaluator< T >::CubicSplineEvaluator().
|
private |
Definition at line 117 of file OneDimCubicSpline.h.
Referenced by CubicSplineEvaluator< T >::cubicInterpolate(), CubicSplineEvaluator< T >::cubicInterpolateSecondDeriv(), and CubicSplineEvaluator< T >::CubicSplineEvaluator().
|
private |
Definition at line 113 of file OneDimCubicSpline.h.
Referenced by CubicSplineEvaluator< T >::CubicSplineEvaluator().
|
private |
Definition at line 114 of file OneDimCubicSpline.h.
Referenced by CubicSplineEvaluator< T >::CubicSplineEvaluator().
|
private |
Definition at line 115 of file OneDimCubicSpline.h.
Referenced by CubicSplineEvaluator< T >::cubicInterpolateSecondDeriv(), and CubicSplineEvaluator< T >::CubicSplineEvaluator().
|
private |
Definition at line 121 of file OneDimCubicSpline.h.
Referenced by CubicSplineEvaluator< T >::cubicInterpolateSecondDeriv(), and CubicSplineEvaluator< T >::CubicSplineEvaluator().
|
private |
Definition at line 122 of file OneDimCubicSpline.h.
Referenced by CubicSplineEvaluator< T >::cubicInterpolateSecondDeriv(), and CubicSplineEvaluator< T >::CubicSplineEvaluator().
|
private |
Definition at line 118 of file OneDimCubicSpline.h.
Referenced by CubicSplineEvaluator< T >::CubicSplineEvaluator().
|
private |
Definition at line 119 of file OneDimCubicSpline.h.
Referenced by CubicSplineEvaluator< T >::cubicInterpolate(), CubicSplineEvaluator< T >::cubicInterpolateSecondDeriv(), and CubicSplineEvaluator< T >::CubicSplineEvaluator().
|
private |
Definition at line 120 of file OneDimCubicSpline.h.
Referenced by CubicSplineEvaluator< T >::cubicInterpolate(), CubicSplineEvaluator< T >::cubicInterpolateSecondDeriv(), and CubicSplineEvaluator< T >::CubicSplineEvaluator().