This function computes the derivatives at the support points xi that can be used as input for evaluating a cubic hermite spline.
If ensureMonotonicity=true
, then the support points yi
need to be monotone increasing (or increasing), and the computed derivatives
di are such that the cubic hermite is monotone increasing (or decreasing).
The algorithm to ensure monotonicity is based on the method described in Fritsch and Carlson (1980) for
ρ = ρ2.
This function is typically used with TRANSFORM.Math.cubicHermiteSplineLinearExtrapolation which is used to evaluate the cubic spline. Because in many applications, the shape of the spline depends on parameters, this function has been implemented in such a way that all derivatives can be computed at once and then stored for use during the time stepping, in which the above function may be called.
F.N. Fritsch and R.E. Carlson, Monotone piecewise cubic interpolation. SIAM J. Numer. Anal., 17 (1980), pp. 238-246.
function splineDerivatives extends TRANSFORM.Icons.Function; input Real x[:] "Support point, strict monotone increasing"; input Real y[size(x, 1)] "Function values at x"; input Boolean ensureMonotonicity = isMonotonic(y, strict = false) "Set to true to ensure monotonicity of the cubic hermite"; output Real d[size(x, 1)] "Derivative at the support points"; end splineDerivatives;