Overview¶
FourierBasis provides a real Fourier series basis for periodic functions. The basis is ordered as , making it convenient for truncated Fourier expansions and their derivatives.
Key Functionality / API¶
CalculateWeights(N, x)returns the real Fourier basis weights.DifferentiationMatrix(N)returns the linear operator for derivatives.DerivativeWeights(N, x)returns weights that evaluate the derivative atx.
Usage Example¶
Evaluate a real Fourier basis, its derivative weights, and a slice of the differentiation matrix.
import numpy as np
import gtsam
np.set_printoptions(precision=3, suppress=True)
N = 7
x = 1.2
weights = gtsam.FourierBasis.CalculateWeights(N, x)
dweights = gtsam.FourierBasis.DerivativeWeights(N, x)
D = gtsam.FourierBasis.DifferentiationMatrix(N)
print("Weights:", np.asarray(weights).ravel())
print("Derivative weights:", np.asarray(dweights).ravel())
print("D[1:3, 1:3]:", np.asarray(D)[1:3, 1:3])Weights: [ 1. 0.362 0.932 -0.737 0.675 -0.897 -0.443]
Derivative weights: [ 0. -0.932 0.362 -1.351 -1.475 1.328 -2.69 ]
D[1:3, 1:3]: [[ 0. 1.]
[-1. 0.]]