BSpline
Create, evaluate, and manipulate one-dimensional terminated B-splines.
Declaration
classdef BSpline < CAAnnotatedClassOverview
BSpline is the low-level one-dimensional spline object used by the higher-level interpolation and fitting classes. It stores a spline degree S, a terminated knot sequence knotPoints, and a coefficient vector xi, then caches an equivalent piecewise-polynomial representation for fast evaluation.
Mathematically, the stored spline is
\[f(t) = x_{\mathrm{Mean}} + x_{\mathrm{Std}} \sum_{j=1}^{M} \xi_j B_{j,S}(t;\tau),\]where \(\tau\) is the terminated knot sequence, \(B_{j,S}\) are the one-dimensional B-spline basis functions of degree \(S\), and xMean is added only for zero-order evaluation.
Basic usage
In most workflows you first build a knot sequence from sample locations, assemble the spline basis matrix, solve for coefficients, and then evaluate the resulting spline object.
t = linspace(0,1,20)';
x = sin(2*pi*t);
knotPoints = BSpline.knotPointsForDataPoints(t, S=3);
X = BSpline.matrixForDataPoints(t, knotPoints=knotPoints, S=3);
spline = BSpline(S=3, knotPoints=knotPoints, xi=X\x);
xq = spline(linspace(0,1,100)');
For advanced antiderivative workflows, BSpline.integratedSplineState(...) returns the canonical spline state of the zero-anchored antiderivative, and BSpline.integralMatrixForDataPoints(...) returns the exact linear map from one-dimensional interpolation values to antiderivative values at chosen query points.
Topics
- Create a spline
BSplineCreate a one-dimensional spline from degree, knots, and coefficients.
- Inspect spline properties
KSpline order K, where polynomial degree is S = K - 1.SPolynomial degree S = K - 1.domainMinimum and maximum values of the spline domain.knotPointsKnot sequence used to define the spline basis.xMeanMean added back to zero-order spline evaluations.xStdMultiplicative scale applied to spline evaluations.xiSpline coefficients as an Mx1 vector.
- Evaluate the spline
fevalEvaluate a B-spline at the supplied points.subsrefEvaluate the spline with function-call syntax or defer to built-in indexing.valueAtPointsEvaluate the spline or one of its derivatives at arbitrary points.
- Transform the spline
cumsumReturn the indefinite integral of a B-spline.diffDifferentiate a B-spline representation.integratedSplineStateReturn the canonical spline state of the zero-anchored antiderivative.mtimesMultiply a spline output by a scalar.plusAdd a scalar offset to a spline output.powerRaise spline values to a real scalar power by refitting support values.rootsReturn real roots of a spline within its domain.sqrtReturn a spline approximation to the square root of the spline output.
- Build spline bases
integralMatrixForDataPointsReturn the exact interpolation-to-antiderivative linear map.knotPointsForDataPointsConstruct a terminated knot sequence from sample locations.matrixForDataPointsEvaluate terminated B-spline basis functions and optional derivatives.pointsOfSupportFromKnotPointsReturn representative support points for a terminated spline basis.
Developer Topics
These items document internal implementation details and are not part of the primary public API.
- Represent piecewise polynomials
CPiecewise-polynomial coefficients for interval evaluation.XtppBasis values and derivatives sampled at piecewise breakpoints.evaluateFromPPCoefficientsEvaluate a cached piecewise-polynomial spline representation.ppCoefficientsFromSplineCoefficientsConvert spline coefficients into piecewise-polynomial interval coefficients.t_ppPiecewise-polynomial breakpoint locations.
- Maintain cached state
splineCoefficientsDidChangeRefresh cached polynomial coefficients after coefficient updates.tKnotDidChangeClear cached piecewise-polynomial data after knot updates.