archimedes.approximationΒΆ

Linear basis-expansion / function approximation infrastructure.

Bases are univariate by default. TensorBasis combines one per dimension into a multivariate basis but otherwise works similarly to the univariate bases.

Two composition primitives build custom bases out of existing ones. ConstrainedBasis recombines one basis’s functions by a fixed matrix (e.g. the nullspace of a boundary condition constraint). ConcatBasis stacks functions from several bases side by side (e.g. spectral-element vertex + bubble functions).

Examples

Project a function onto a degree-5 Legendre space and evaluate it:

>>> import numpy as np
>>> from archimedes import approximation as approx
>>> space = approx.FunctionSpace.legendre(n_basis=6)
>>> f = space.project(lambda x: np.sin(np.pi * x))
>>> round(float(f(np.array([0.5]))[0]), 3)
1.005

Classes

BSplineBasis(degree, knots)

Univariate B-spline basis on a general knot vector.

Basis()

A finite-dimensional family of basis functions \(\{\phi_i\}_{i=1}^n\).

BasisMatrix(matrix, weights, nodes)

A Basis evaluated at a set of quadrature nodes.

ConcatBasis(pieces, quad_rule)

A basis made of combining other bases.

ConstrainedBasis(base, matrix)

A basis whose functions are fixed linear combinations of another's

CubicHermiteBasis()

A basis of cubic Hermite shape functions

FourierBasis(n_basis[, kind, density])

Trigonometric basis on a periodic interval.

Function(coefficients, space)

A specific element of a FunctionSpace:

FunctionSpace(basis, domain[, ...])

The linear span of a Basis on a fixed target domain.

LagrangeBasis(reference_nodes[, node_family])

Lagrange (nodal) interpolating polynomial basis

MonomialBasis(n_basis)

Monomial (power series) basis on an interval.

OrthogonalPolynomialBasis(measure, n_basis)

A classical orthonormal polynomial basis

PiecewiseBasis(element_basis, breakpoints[, ...])

A Basis constructed by tiling a local basis across elements.

ProductParameters([dims])

Target-domain parameters for a TensorBasis

TensorBasis(bases)

Tensor product of univariate bases, one per dimension.