Overview¶
The Basis class is a CRTP base class that defines common utilities for representing functions as linear combinations of basis functions. Derived classes provide CalculateWeights and DerivativeWeights, while Basis supplies functors and helpers for evaluation, vector-valued evaluation, and derivative computation with Jacobians with respect to parameters.
Key Functionality / API¶
WeightMatrix(N, X)andWeightMatrix(N, X, a, b)build stacked weight matrices.EvaluationFunctorevaluates a scalar function atx.VectorEvaluationFunctorevaluates vector-valued functions from a parameter matrix.VectorComponentFunctorevaluates a single component of a vector-valued function.ManifoldEvaluationFunctorevaluates manifold-valued functions via local coordinates.DerivativeFunctor,VectorDerivativeFunctor, andComponentDerivativeFunctorcompute derivatives.kroneckerProductIdentitybuilds efficient block Jacobians for vector-valued cases.
Derived Classes¶
Chebyshev1Basis(first-kind Chebyshev polynomials)Chebyshev2Basis(second-kind Chebyshev polynomials)FourierBasis(real Fourier series)Chebyshev2(pseudo-spectral Chebyshev points)
Usage Example¶
This example builds a weight matrix for a Chebyshev basis and evaluates Fourier weights at a point.
import numpy as np
import gtsam
np.set_printoptions(precision=3, suppress=True)
N = 5
X = np.linspace(-1.0, 1.0, 5)
W = gtsam.Chebyshev2.WeightMatrix(N, X)
print("Chebyshev2 WeightMatrix shape:", np.asarray(W).shape)
print("First row:", np.asarray(W)[0])
x = 0.3
weights = gtsam.FourierBasis.CalculateWeights(N, x)
print("FourierBasis weights at x=0.3:", np.asarray(weights).ravel())
Chebyshev2 WeightMatrix shape: (5, 5)
First row: [1. 0. 0. 0. 0.]
FourierBasis weights at x=0.3: [1. 0.955 0.296 0.825 0.565]