Given the arrays X and Y, which tabulate a function (with the Xi in ascending order), and given the array Y2, which is the output from SPL_INIT, and given an input value of X2, the SPL_INTERP function returns a cubic-spline interpolated value for the given value of XI.
SPL_INTERP is based on the routine splint described in section 3.3 of Numerical Recipes in C: The Art of Scientific Computing (Second Edition), published by Cambridge University Press, and is used by permission.
To create a spline interpolation over a tabulated set of data, [Xi, Yi], first create the tabulated data. In this example, Xi will be in the range [0.0, 2π] and Yi in the range [sin(0.0), sin(2π)].
X = (FINDGEN(21)/20.0) * 2.0 * !PI
Y = SIN(X)
; Calculate interpolating cubic spline:
Y2 = SPL_INIT(X, Y)
; Define the X values P at which we desire interpolated Y values:
X2= FINDGEN(11)/11.0 * !PI
; Calculate the interpolated Y values corresponding to X2[i]:
result = SPL_INTERP(X, Y, Y2, X2)
0.00000 0.281733 0.540638 0.755739 0.909613 0.989796
0.989796 0.909613 0.755739 0.540638 0.281733
The exact solution vector is sin(X2).
To interpolate a line in the XY plane, see SPLINE_P.
Result = SPL_INTERP( X, Y, Y2, X2 [, /DOUBLE] )
Returns either single- or double-precision floating result of the same structure as X2.
An input array that specifies the tabulated points in ascending order.
An input array that specifies the values of the tabulate function corresponding to Xi.
The output from SPL_INIT for the specified X and Y.
The input value for which an interpolated value is desired. X can be scalar or an array of values. The result of SPL_INTERP will have the same structure.
Set this keyword to force the computation to be done in double-precision arithmetic.
This page has no comments yet. Be the first one!