Loading...
Searching...
No Matches
Fourier.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/basis/Basis.h>
namespace gtsam {
class FourierBasis : public Basis<FourierBasis> {
public:
using Parameters = Eigen::Matrix<double, /*Nx1*/ -1, 1>;
using DiffMatrix = Eigen::Matrix<double, /*NxN*/ -1, -1>;
static Weights CalculateWeights(size_t N, double x) {
Weights b(N);
b[0] = 1;
for (size_t i = 1, n = 1; i < N; i++) {
if (i % 2 == 1) {
b[i] = cos(n * x);
} else {
b[i] = sin(n * x);
n++;
}
}
return b;
}
static Weights CalculateWeights(size_t N, double x, double a, double b) {
// TODO(Varun) How do we enforce an interval for Fourier series?
return CalculateWeights(N, x);
}
static DiffMatrix DifferentiationMatrix(size_t N) {
DiffMatrix D = DiffMatrix::Zero(N, N);
double k = 1;
for (size_t i = 1; i < N; i += 2) {
D(i, i + 1) = k; // sin'(k*x) = k*cos(k*x)
D(i + 1, i) = -k; // cos'(k*x) = -k*sin(k*x)
k += 1;
}
return D;
}
static Weights DerivativeWeights(size_t N, double x) {
return CalculateWeights(N, x) * DifferentiationMatrix(N);
}
static Weights DerivativeWeights(size_t N, double x, double a, double b) {
return CalculateWeights(N, x, a, b) * DifferentiationMatrix(N);
}
}; // FourierBasis
} // namespace gtsam
Basis.h
Compute an interpolating basis.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::Basis
CRTP Base class for function bases.
Definition Basis.h:100
gtsam::FourierBasis
Fourier basis.
Definition Fourier.h:27
gtsam::FourierBasis::DifferentiationMatrix
static DiffMatrix DifferentiationMatrix(size_t N)
Compute D = differentiation matrix.
Definition Fourier.h:73
gtsam::FourierBasis::DerivativeWeights
static Weights DerivativeWeights(size_t N, double x)
Get weights at a given x that calculate the derivative.
Definition Fourier.h:92
gtsam::FourierBasis::CalculateWeights
static Weights CalculateWeights(size_t N, double x)
Evaluate Real Fourier Weights of size N in interval [a, b], e.g.
Definition Fourier.h:40
gtsam::FourierBasis::DerivativeWeights
static Weights DerivativeWeights(size_t N, double x, double a, double b)
Get derivative weights at a given x that calculate the derivative, in the interval [a,...
Definition Fourier.h:106
gtsam::FourierBasis::CalculateWeights
static Weights CalculateWeights(size_t N, double x, double a, double b)
Evaluate Real Fourier Weights of size N in interval [a, b], e.g.
Definition Fourier.h:64