XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ pchsp()

void pchsp ( int  ic[],
double  vc[],
int  n,
double  x[],
double  f[],
double  d[],
int  incfd,
double  work[],
int  lwork,
int *  info 
)

Piecewise cubic spline interpolation

Purpose
This routine computes the derivatives needed to determine the Hermite representation of the cubic spline interpolant to given data, with specified boundary conditions.

The resulting piecewise cubic spline function may be evaluated by pchfe or pchfd.
Parameters
[in]ic[]Array ic[2]
Specifies desired boundary conditions.
ic[0] = ibeg, desired condition at beginning of data.
ic[1] = iend, desired condition at end of data.

ibeg = 0: To set d[0] so that the third derivative is continuous at x[1]. This is the "not a knot" condition, which is the default boundary condition.
ibeg = 1: The first derivative at x[0] is given in vc[0].
ibeg = 2: The second derivative at x[0] is given in vc[0]. For the "natural" boundary condition, use ibeg = 2 and vc[0] = 0.
ibeg = 3: To use the 3-point difference formula for d[0] (reverts to the default boundary conditions if n < 3).
ibeg = 4: To use the 4-point difference formula for d[0] (reverts to the default boundary conditions if n < 4).

iend may take on the same values as ibeg, but applied to derivative at x[n-1]. In the case iend = 1 or 2, the value is given in vc[1]. For the "natural" boundary condition, use iend = 2 and vc[1] = 0.
[in]vc[]Array vc[2]
Specifies desired boundary values, as indicated above.
vc[0] need to be set only if ic[0] = 1 or 2.
vc[1] need to be set only if ic[1] = 1 or 2.
[in]nNumber of data points. (n >= 2)
[in]x[]Array x[lx] (lx >= n)
Independent variable values. The elements of x[] must be strictly increasing.
[in]f[]Array f[lf] (lf >= incfd*(n - 1) + 1)
Dependent variable values to be interpolated. f[i*incfd] is the value corresponding to x[i] (i = 0 to n - 1).
[out]d[]Array d[ld] (ld >= incfd*(n - 1) + 1)
Derivative values at the data points. These values will determine the cubic spline interpolant with the requested boundary conditions. The value corresponding to x[i] is stored in d[i*incfd] (i = 0 to n - 1). No other entries in d[] are changed.
[in]incfdIncrement between successive values in f[] and d[]. This argument is provided primarily for 2-D applications. (incfd >= 1)
[out]work[]Array work[lwork]
Work array.
[in]lworkThe dimension of the array work[] (lwork >= 2*n)
[out]info= 0: Successful exit
= -1: The argument ic had an illegal value (ic[0] < 0 or ic[0] > 4, ic[1] < 0 or ic[1] > 4)
= -3: The argument n had an illegal value (n < 2)
= -4: The argument x had an illegal value (x[] is not strictly increasing)
= -7: The argument incfd had an illegal value (incfd < 1)
= -9: The argument lwork had an illegal value (lwork < 2*n)
Reference
SLATEC (PCHIP)