The functions listed below help with common use cases of B-splines. See their docstrings for more information.
The knotaverages
function returns a vector \tau
of knot averages
where t
is the knot vector of the B-spline basis and k
is its order.
The length of \tau
equals the number of B-splines in the basis.
The knot averages are recommended in 1 (p. 214) as data points for interpolation.
Instead of creating the knot vector for all indices i
, a range of indices can be supplied with the keyword argument indices
.
The knotaverages!
function can be used to write the knot averages to a pre-allocated array.
The averagebasis
function returns a BSplineBasis
of a specified order that is well-suited for interpolating a function at a given set of data points.
!!! warning
To obtain a valid B-spline basis, the data points must be sorted in ascending order.
This is not checked by the averagebasis
function.
The basismatrix
function calculates the matrix
where B_j
is the j
-th B-spline of a basis and x
is a vector of real numbers.
The range of indices j
can be supplied with the indices
keyword argument.
The basismatrix!
function can be used to write B_{ij}
to a pre-allocated array.
The interpolate
function interpolates data (vectors of x
and y
values) in a given B-spline basis.
It returns a Spline
.
The indices
keyword can be used to restrict the interpolation to a range of B-splines from the basis.
The approximate
function approximates a function f:\mathbb{R}\to\mathbb{R}
in a given B-spline basis by sampling the function at the knot averages of the basis and interpolating the samples.
The indices
keyword can be used to restrict the B-splines used for the interpolation.
Footnotes
-
Carl de Boor, A Practical Guide to Splines, New York, N.Y.: Springer, 1978. ↩