Fourier.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
20 #pragma once
21 
22 #include <gtsam/basis/Basis.h>
23 
24 namespace gtsam {
25 
27 class FourierBasis : public Basis<FourierBasis> {
28  public:
29  using Parameters = Eigen::Matrix<double, /*Nx1*/ -1, 1>;
30  using DiffMatrix = Eigen::Matrix<double, /*NxN*/ -1, -1>;
31 
40  static Weights CalculateWeights(size_t N, double x) {
41  Weights b(N);
42  b[0] = 1;
43  for (size_t i = 1, n = 1; i < N; i++) {
44  if (i % 2 == 1) {
45  b[i] = cos(n * x);
46  } else {
47  b[i] = sin(n * x);
48  n++;
49  }
50  }
51  return b;
52  }
53 
64  static Weights CalculateWeights(size_t N, double x, double a, double b) {
65  // TODO(Varun) How do we enforce an interval for Fourier series?
66  return CalculateWeights(N, x);
67  }
68 
74  DiffMatrix D = DiffMatrix::Zero(N, N);
75  double k = 1;
76  for (size_t i = 1; i < N; i += 2) {
77  D(i, i + 1) = k; // sin'(k*x) = k*cos(k*x)
78  D(i + 1, i) = -k; // cos'(k*x) = -k*sin(k*x)
79  k += 1;
80  }
81 
82  return D;
83  }
84 
92  static Weights DerivativeWeights(size_t N, double x) {
94  }
95 
106  static Weights DerivativeWeights(size_t N, double x, double a, double b) {
107  return CalculateWeights(N, x, a, b) * DifferentiationMatrix(N);
108  }
109 
110 }; // FourierBasis
111 
112 } // namespace gtsam
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. N=5 yields bases: 1,...
Definition: Fourier.h:64
D
MatrixXcd D
Definition: EigenSolver_EigenSolver_MatrixType.cpp:14
ceres::sin
Jet< T, N > sin(const Jet< T, N > &f)
Definition: jet.h:439
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
gtsam::Basis
Definition: Basis.h:90
gtsam::FourierBasis::CalculateWeights
static Weights CalculateWeights(size_t N, double x)
Evaluate Real Fourier Weights of size N in interval [a, b], e.g. N=5 yields bases: 1,...
Definition: Fourier.h:40
ceres::cos
Jet< T, N > cos(const Jet< T, N > &f)
Definition: jet.h:426
n
int n
Definition: BiCGSTAB_simple.cpp:1
Basis.h
Compute an interpolating basis.
gtsam::FourierBasis
Fourier basis.
Definition: Fourier.h:27
gtsam::b
const G & b
Definition: Group.h:79
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
gtsam
traits
Definition: SFMdata.h:40
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
Eigen::Matrix< double, -1, 1 >
N
#define N
Definition: igam.h:9
gtsam::FourierBasis::DifferentiationMatrix
static DiffMatrix DifferentiationMatrix(size_t N)
Definition: Fourier.h:73
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:18