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

◆ pchbs()

void pchbs ( int  n,
double  x[],
double  f[],
double  d[],
int  incfd,
int  knotyp,
int *  nknots,
double  t[],
double  bcoef[],
int *  ndim,
int *  kord,
int *  info 
)

Piecewise cubic Hermite to B-spline conversion

Purpose
This routine computes the B-spline representation of the piecewise cubic Hermite function determined by n, x[], f[] and d[]. The output is the B-representation for the function: nknots, t[], bcoef[], ndim and kord.

Since it is assumed that the input piecewise cubic Hermite function has been computed by one of the other routines in the package, input arguments n, x[], incfd are not checked for validity.

Restrictions and assumptions are:
  1. n >= 2 (not checked)
  2. x[i] < x[i+1], i=0 to n-1 (not checked)
  3. incfd > 0 (not checked)
  4. knotyp <= 2 (error return if not)
  5. (*) nknots = ndim + 4 = 2*n + 4 (error return if not)
  6. (*) t[2*k + 1] = t[2*k] = x[k], k=0 to n-1 (not checked)
(*): indicates this applies only if knotyp < 0.
Parameters
[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)
Function values. f[i*incfd] is the value corresponding to x[i] (i = 0 to n - 1).
[in]d[]Array d[ld] (ld >= incfd*(n - 1) + 1)
Derivative values. d[i*incfd] is the value corresponding to x[i] (i = 0 to n - 1).
[in]incfdIncrement between successive values in f[] and d[]. (incfd >= 1)
[in]knotypFlag to control the knot sequence.
The knot sequence t[] is normally computed from x by putting a double knot at each x and setting the end knot pairs according to the value of knotyp.
= 0: Quadruple knots at x[0] and x[n-1]
= 1: Replicate lengths of extreme subintervals:
  t[0] = t[1] = x[0] - (x[1] - x[0])
  t[m + 3] = t[m + 2] = x[n - 1] + (x[n - 1] - x[n - 2])
= 2: Periodic placement of boundary knots:
  t[0] = t[1] = x[0] - (x[n - 1] - x[n - 2])
  t[m + 3] = t[m + 2] = x[n - 1] + (x[1] - x[0])
Here m = ndim = 2*n.
If the input value of knotyp is negative, however, it is assumed that nknots and t[] were set in a previous call. This option is provided for improved efficiency when used in a parametric setting.
[in,out]nknotsNumber of knots. [in] When knotyp < 0: nknots is an input variable, and an error return will be taken if it is not equal to ndim + 4. [out] When knotyp >= 0: nknots will be set to ndim + 4.
[in,out]t[]Array t[lt] (lt >= 2*n + 4)
Knots for the B-representation.
[in] When knotyp < 0: It is assumed that t[] was set by a previous call to pchbs (This routine does not verify that t[] forms a legitimate knot sequence).
[out] When knotyp >= 0: t[] will be returned by pchbs with the interior double knots equal to the x values and the boundary knots set as indicated above.
[out]bcoef[]Array bcoef[lbcoef] (lbcoef >= 2*n)
B-spline coeficients.
[out]ndimDimension of the B-spline space (set to 2*n).
[out]kordOrder of the B-spline (set to 4).
[out]info= 0: Successful exit
= -6: The argument knotyp had an illegal value (knotyp > 2)
= -7: The argument nknots had an illegal value (nknots != 2*N+4 when knotyp < 0)
Reference
SLATEC (PCHIP)