|
IDL Analyst Reference Guide: Interpolation and Approximation |
|
The IMSL_CSINTERP function computes a cubic spline interpolant, specifying various endpoint conditions. The default interpolant satisfies the not-a-knot condition.
| Note This routine requires an IDL Analyst license. For more information, contact your ITT Visual Information Solutions sales or technical support representative. |
Result = IMSL_CSINTERP(xdata, fdata [, /DOUBLE] [, /ILEFT=value]
[, /IRIGHT=value] [, /LEFT=value] [, /PERIODIC] [, /RIGHT=value])
A structure that represents the cubic spline interpolant.
One-dimensional array containing the abscissas of the interpolation problem.
One-dimensional array containing the ordinates for the interpolation problem.
If present and nonzero, double precision is used.
Sets the value for the first or second derivative of the interpolant at the left endpoint. The keyword ILEFT is used to specify which derivative is set: ILEFT = 1 for the first derivative and ILEFT = 2 for the second derivative. The only valid values for ILEFT are 1 or 2. If ILEFT is specified, then the keyword LEFT also must be used.
Sets the value for the first or second derivative of the interpolant at the right endpoint. The keyword IRIGHT is used to specify which derivative is set: IRIGHT = 1 for the first derivative and IRIGHT = 2 for the second derivative. The only valid values for IRIGHT are 1 or 2. If IRIGHT is specified, then the keyword RIGHT also must be used.
Sets the value for the first or second derivative of the interpolant at the left endpoint. Use with the keyword ILEFT. If ILEFT = i, then the interpolant s satisfies s(i)(xL) = LEFT. Here, xL is the leftmost abscissa.
If present and nonzero, computes the C2 periodic interpolant to the data. The following is satisfied:
s(i) (xL) = s(i) (xR) i = 0, 1, 2
where s, xL, and xR are defined above.
Sets the value for the first or second derivative of the interpolant at the right endpoint. Use with the keyword IRIGHT. If IRIGHT = i, then the interpolant s satisfies s(i)(xR) = RIGHT. Here, xR is the rightmost abscissa.
The IMSL_CSINTERP function computes a C2 cubic spline interpolant to a set of data points (xi, fi) for the following:
i = 0, ..., (N_ELEMENTS(xdata) – 1) = (n – 1)
The breakpoints of the spline are the abscissas. For all univariate interpolation functions, the abscissas need not be sorted. Endpoint conditions are to be selected by the user. The user can specify not-a-knot, or first or second derivatives at each endpoint or C2 periodicity can be requested (see de Boor 1978, Chapter 4). If no defaults are selected, then the not-a-knot spline interpolant is computed. If the PERIODIC keyword is selected, then all other keywords are ignored and a C2 is computed. In this case, if the fdata values at the left and right endpoints are not the same, a warning message is issued and the right value is set equal to the left. If the LEFT and ILEFT or RIGHT and IRIGHT keywords are used, the user has the ability to select the values of the first or second derivative at either endpoint. The default case (when the keyword is not used) is the not-a-knot condition on that endpoint. Thus, when no keywords are chosen, this function produces the not-a-knot interpolant.
If the data (including the endpoint conditions) arise from the values of a smooth (for example, C4) function f, i.e., fi = f(xi), then the error behaves in a predictable fashion. Let x be the breakpoint vector for the above spline interpolant. Then, the maximum absolute error satisfies:

where the following is true:

In this example, a cubic spline interpolant, as shown in Figure 6-1, to function values is computed and plotted along with the original data. Since the default settings are used, the interpolant is determined by the not-a-knot condition (see de Boor 1978).
x = FINDGEN(11)/10 ; Generate the abscissas. f = SIN(15 * x) ; Generate the function values. pp = IMSL_CSINTERP(x, f) ; Compute the spline interpolant. ppval = IMSL_SPVALUE(FINDGEN(100)/99, pp) PLOT, FINDGEN(100)/99, ppval ; Plot the results. OPLOT, x, f, Psym = 6
In this example, a cubic spline interpolant to function values is computed. The value of the derivative at the left endpoint and the value of the second derivative at the right endpoint are specified. The resulting spline and original data are then plotted as shown in Figure 6-2.
x = FINDGEN(11)/10 y = SIN(15 * x) pp = IMSL_CSINTERP(x, y, ILeft = 1, Left = 0, $ IRight = 2, Right = -225 * SIN(15)) ppval = IMSL_SPVALUE(FINDGEN(100)/99, pp) PLOT, FINDGEN(100)/99, ppval OPLOT, x, y, Psym = 6
|
![]()
|
MATH_NOT_PERIODIC—Data are not periodic. The rightmost fdata value is set to the leftmost fdata value.
MATH_DUPLICATE_XDATA_VALUES—The xdata values must be distinct.
IDL Online Help (March 06, 2007)