ParameterMatrix as a separate static method

release/4.3a0
Varun Agrawal 2023-10-23 17:57:07 -04:00
parent 3bff8ad317
commit 9ee652c04a
4 changed files with 22 additions and 2 deletions

View File

@ -34,6 +34,11 @@ struct GTSAM_EXPORT Chebyshev1Basis : Basis<Chebyshev1Basis> {
Parameters parameters_;
/// Return a zero initialized Parameter matrix.
static Parameters ParameterMatrix(size_t N) {
return Parameters::Zero(N);
}
/**
* @brief Evaluate Chebyshev Weights on [-1,1] at x up to order N-1 (N values)
*
@ -80,6 +85,11 @@ struct GTSAM_EXPORT Chebyshev1Basis : Basis<Chebyshev1Basis> {
struct GTSAM_EXPORT Chebyshev2Basis : Basis<Chebyshev2Basis> {
using Parameters = Eigen::Matrix<double, -1, 1 /*Nx1*/>;
/// Return a zero initialized Parameter matrix.
static Parameters ParameterMatrix(size_t N) {
return Parameters::Zero(N);
}
/**
* Evaluate Chebyshev Weights on [-1,1] at any x up to order N-1 (N values).
*

View File

@ -54,7 +54,7 @@ class GTSAM_EXPORT Chebyshev2 : public Basis<Chebyshev2> {
/**
* @brief Specific Chebyshev point, within [a,b] interval.
* Default interval is [-1, 1]
*
*
* @param N The degree of the polynomial
* @param j The index of the Chebyshev point
* @param a Lower bound of interval (default: -1)
@ -86,6 +86,11 @@ class GTSAM_EXPORT Chebyshev2 : public Basis<Chebyshev2> {
return points;
}
/// Return a zero initialized Parameter matrix.
static Parameters ParameterMatrix(size_t N) {
return Parameters::Zero(N + 1);
}
/**
* Evaluate Chebyshev Weights on [-1,1] at any x up to order N-1 (N values)
* These weights implement barycentric interpolation at a specific x.

View File

@ -74,7 +74,7 @@ class FitBasis {
const Sequence& sequence, const SharedNoiseModel& model, size_t N) {
NonlinearFactorGraph graph = NonlinearGraph(sequence, model, N);
Values values;
values.insert<Parameters>(0, Parameters::Zero(N));
values.insert<Parameters>(0, Basis::ParameterMatrix(N));
GaussianFactorGraph::shared_ptr gfg = graph.linearize(values);
return gfg;
}

View File

@ -51,6 +51,11 @@ class FourierBasis : public Basis<FourierBasis> {
return b;
}
/// Return a zero initialized Parameter matrix.
static Parameters ParameterMatrix(size_t N) {
return Parameters::Zero(N);
}
/**
* @brief Evaluate Real Fourier Weights of size N in interval [a, b],
* e.g. N=5 yields bases: 1, cos(x), sin(x), cos(2*x), sin(2*x)