Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 2.13 KB

functions.md

File metadata and controls

49 lines (34 loc) · 2.13 KB

Higher-level functions

The functions listed below help with common use cases of B-splines. See their docstrings for more information.

knotaverages/knotaverages!

The knotaverages function returns a vector \tau of knot averages

$$\tau_i = \frac{1}{k-1} \sum_{j=i+1}^{i+k-1} t_j$$

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.

averagebasis

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.

basismatrix/basismatrix!

The basismatrix function calculates the matrix

$$B_{ij} = B_j(x_i)$$

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.

interpolate

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.

approximate

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

  1. Carl de Boor, A Practical Guide to Splines, New York, N.Y.: Springer, 1978.