Given the arrays X and Y , which tabulate a function (with the X i in ascending order), and given the array Y 2 , which is the output from SPL_INIT, and given an input value of X 2 , the SPL_INTERP function returns a cubic-spline interpolated value for the given value of X I . The result has the same structure as X 2 , and is either single- or double-precision floating, based on the input type.
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, [ X i , Y i ], first create the tabulated data. In this example, X i will be in the range [0.0, 2p] and Y i in the range [sin(0.0), sin(2p)].
X = (FINDGEN(21)/20.0) * 2.0 * !PI
Y 2 = SPL_INIT(X, Y) ; Calculate interpolating cubic spline.
X 2 = FINDGEN(11)/11.0 * !PI ; Define the X values P at which we desire interpolated Y values.
result = SPL_INTERP(X, Y, Y 2 , X 2 ) ; Calculate the interpolated Y values corresponding to X 2 ; [i].
0.00000 0.281733 0.540638 0.755739 0.909613 0.989796
0.989796 0.909613 0.755739 0.540638 0.281733