archimedes.approximation.BSplineBasis¶

class archimedes.approximation.BSplineBasis(degree: int, knots: ndarray)¶

Univariate B-spline basis on a general knot vector.

The \(j\)-th B-spline basis function is \(B_{j, k; \mathbf{x}}\) for degree \(k\) and nondecreasing knot vector \(\mathbf{x}\). Following de Boor’s conventions in [1] and [2], the \(\mathbf{x}\) subscript will be dropped in the following notation. The basis functions are defined recursively starting from the zeroth degree as

\[\begin{split}B_{j, 0}(x) = \begin{cases} 1 & \text{if } x_j \le x < x_{j+1}, \\ 0 & \text{otherwise}, \end{cases}\end{split}\]

and for higher degrees \(k \ge 1\) as

\[B_{j, k}(x) = \omega_{j, k}(x) B_{j, k-1}(x) + (1 - \omega_{j+1, k}(x)) B_{j+1, k-1}(x),\]

with weight functions

\[\begin{split}\omega_{j, k}(x) = \begin{cases} \frac{x - x_j}{x_{j+k} - x_j} & \text{if } x_{j+k} \neq x_j, \\ 0 & \text{otherwise}. \end{cases}\end{split}\]

A function approximated in the B-spline basis for a given knot vector can be expressed in the usual basis expansion:

\[f(x) \approx \sum_j c_j B_{j, k}(x)\]

The knot vector can contain any interior or end multiplicity from \(1\) through \(k + 1\), clamped or open. A knot of multiplicity \(k + 1\) produces a true discontinuity, while a knot of multiplicity \(m < k + 1\) produces \(C^{k - m}\) continuity.

Parameters:
  • degree (int) – Polynomial degree \(k\) of each piece.

  • knots (array_like) – Nondecreasing knot vector \(\mathbf{x}\) in physical units, length n_basis + degree + 1.

See also

FunctionSpace.bspline

Convenience constructor deriving Parameters automatically from an explicit knot vector.

FunctionSpace.clamped_bspline

Convenience constructor building a clamped knot vector from physical breakpoints (the common case).

Notes

Unlike the piecewise polynomial basis, the knot vector is defined in physical space (not a normalized reference domain).

Periodic (closed-curve) B-splines are not supported.

On the basic interval \([x_k, x_n]\) (\(n\) = n_basis), the basis functions are nonnegative and form a partition of unity, \(\sum_j B_{j, k}(x) = 1\). Outside it, evaluation extrapolates using the polynomial piece of the boundary span, matching the default behavior of scipy.interpolate.BSpline [3].

In this implementation the knot vector must be static, i.e. the values cannot be traced symbolically or optimized over.

References

Methods

boundary_dofs([order])

Indices of the boundary degrees of freedom for a given derivative order.

evaluate(x[, deriv, a, b, side])

Evaluate all n_basis B-splines at x using de Boor's BSPLVB algorithm.

Attributes

Parameters

Type of the parameters for the B-spline basis (ignored for this class).

density

Whether this basis is orthonormal with respect to a probability measure (unit mass) rather than the raw weight of the associated Measure.

n_basis

Number of B-spline basis functions.

ndim

Number of independent variables the basis functions take.

degree

Polynomial degree of the B-spline basis.

knots

Nondecreasing knot vector.

__init__(degree: int, knots: ndarray) → None¶
boundary_dofs(order: int = 0) → tuple[int | None, int | None]¶

Indices of the boundary degrees of freedom for a given derivative order.

Returns indices of the degrees of freedom corresponding to the order-th derivative at the left and right ends of the domain.

If knots is clamped (multiplicity degree + 1 at both ends), the first and last coefficients correspond to the endpoint values. Otherwise, returns (None, None), since interior coefficients are control points.

evaluate(x, deriv: int = 0, *, a=None, b=None, side: str = RIGHT)¶

Evaluate all n_basis B-splines at x using de Boor’s BSPLVB algorithm.

The domain endpoints a and b are accepted for compatibility with the base class Basis.evaluate(), but are ignored here, since the domain is already determined by the knot vector.

property Parameters: type¶

Type of the parameters for the B-spline basis (ignored for this class).

degree: int¶

Polynomial degree of the B-spline basis.

density: bool = False¶

Whether this basis is orthonormal with respect to a probability measure (unit mass) rather than the raw weight of the associated Measure.

Only meaningful for orthogonal polynomial families based on a Measure (in particular OrthogonalPolynomialBasis); other families should leave this False.

knots: ndarray¶

Nondecreasing knot vector.

property n_basis: int¶

Number of B-spline basis functions.

ndim: int = 1¶

Number of independent variables the basis functions take.

Typically 1, since most bases are univariate. TensorBasis is the exception, with one variable per tensored factor.