BSpline

Create, evaluate, and manipulate one-dimensional terminated B-splines.


Declaration

classdef BSpline < CAAnnotatedClass

Overview

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
    • BSpline Create a one-dimensional spline from degree, knots, and coefficients.
  • Inspect spline properties
    • K Spline order K, where polynomial degree is S = K - 1.
    • S Polynomial degree S = K - 1.
    • domain Minimum and maximum values of the spline domain.
    • knotPoints Knot sequence used to define the spline basis.
    • xMean Mean added back to zero-order spline evaluations.
    • xStd Multiplicative scale applied to spline evaluations.
    • xi Spline coefficients as an Mx1 vector.
  • Evaluate the spline
    • feval Evaluate a B-spline at the supplied points.
    • subsref Evaluate the spline with function-call syntax or defer to built-in indexing.
    • valueAtPoints Evaluate the spline or one of its derivatives at arbitrary points.
  • Transform the spline
    • cumsum Return the indefinite integral of a B-spline.
    • diff Differentiate a B-spline representation.
    • integratedSplineState Return the canonical spline state of the zero-anchored antiderivative.
    • mtimes Multiply a spline output by a scalar.
    • plus Add a scalar offset to a spline output.
    • power Raise spline values to a real scalar power by refitting support values.
    • roots Return real roots of a spline within its domain.
    • sqrt Return a spline approximation to the square root of the spline output.
  • Build spline bases

Developer Topics

These items document internal implementation details and are not part of the primary public API.

  • Represent piecewise polynomials
    • C Piecewise-polynomial coefficients for interval evaluation.
    • Xtpp Basis values and derivatives sampled at piecewise breakpoints.
    • evaluateFromPPCoefficients Evaluate a cached piecewise-polynomial spline representation.
    • ppCoefficientsFromSplineCoefficients Convert spline coefficients into piecewise-polynomial interval coefficients.
    • t_pp Piecewise-polynomial breakpoint locations.
  • Maintain cached state