Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Basis

Open In Colab

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) and WeightMatrix(N, X, a, b) build stacked weight matrices.

  • EvaluationFunctor evaluates a scalar function at x.

  • VectorEvaluationFunctor evaluates vector-valued functions from a parameter matrix.

  • VectorComponentFunctor evaluates a single component of a vector-valued function.

  • ManifoldEvaluationFunctor evaluates manifold-valued functions via local coordinates.

  • DerivativeFunctor, VectorDerivativeFunctor, and ComponentDerivativeFunctor compute derivatives.

  • kroneckerProductIdentity builds 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]

Source