26 using namespace gtsam;
28 auto model = noiseModel::Unit::Create(1);
34 (Vector7() << 1.5661, 1.2717, 1.2717, -0.0000, 0.5887, -0.0943, 0.0943)
43 FourierBasis::EvaluationFunctor
fx(3, 0);
53 FourierBasis::EvaluationFunctor
fx(3, 0);
57 Matrix13 expectedH(1, 1, 0);
76 for (
size_t i = 0;
i < 16;
i++) {
77 const double x =
i *
M_PI / 8;
86 graph.
add(linearFactor);
95 auto linearizedFactor = predictFactor.
linearize(values);
96 auto linearizedJacobianFactor =
98 CHECK(linearizedJacobianFactor);
114 for (
size_t i = 0;
i < 16;
i++) {
122 values.insert<
Vector>(
key, Vector::Zero(7));
134 expected.row(0) << 1,
cos(1),
sin(1);
135 expected.row(1) << 1,
cos(2),
sin(2);
137 Matrix actual = FourierBasis::WeightMatrix(3, X);
145 for (
size_t i = 0;
i < 16;
i++) {
167 const double x = 0.2;
168 Matrix numeric_dTdx = numericalDerivative11<double, double>(
proxy,
x);
171 Matrix D7 = FourierBasis::DifferentiationMatrix(7);
173 FourierBasis::EvaluationFunctor
fx(7, x);
177 FourierBasis::DerivativeFunctor dfdx(7, x);
183 using DotShape =
typename FourierBasis::VectorDerivativeFunctor;
187 double h = 2 *
M_PI / 16;
188 Vector2 dotShape(0.5556, -0.8315);
189 DotShape dotShapeFunction(2, N, h / 2);
190 Matrix theta = (Matrix32() << 0, 0, 0.7071, 0.7071, 0.7071, -0.7071)
217 const Matrix W = FourierBasis::WeightMatrix(N, X);
221 using Eval = FourierBasis::EvaluationFunctor;
227 const Matrix invW = W.inverse();
230 for (
size_t i = 0;
i < 16;
i++) {
231 const double x =
i *
M_PI / 8;
240 graph.
add(linearFactor);
const gtsam::Symbol key('X', 0)
Jet< T, N > cos(const Jet< T, N > &f)
Concept check for values that can be used in unit tests.
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
static int runAllTests(TestResult &result)
const Vector7 k7Coefficients
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Jet< T, N > sin(const Jet< T, N > &f)
Fourier decomposition, see e.g. http://mathworld.wolfram.com/FourierSeries.html.
TEST(Basis, BasisEvaluationFunctor)
Evaluate derivatives of a nonlinear factor numerically.
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
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 y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange [*:*] noreverse nowriteback set trange [*:*] noreverse nowriteback set urange [*:*] noreverse nowriteback set vrange [*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
NonlinearFactorGraph graph
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
VectorValues optimize(const Eliminate &function=EliminationTraitsType::DefaultEliminate) const
std::shared_ptr< GaussianFactorGraph > linearize(const Values &linearizationPoint) const
Linearize a nonlinear factor graph.
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
const Vector k3Coefficients
void add(const GaussianFactor &factor)
std::map< double, double > Sequence
Our sequence representation is a map of {x: y} values where y = f(x)
Factor for enforcing the scalar value of the polynomial BASIS representation at x is the same as the ...
#define EXPECT(condition)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
std::shared_ptr< This > shared_ptr
shared_ptr to this class
std::shared_ptr< GaussianFactor > linearize(const Values &x) const override
#define EXPECT_CORRECT_FACTOR_JACOBIANS(factor, values, numerical_derivative_step, tolerance)
Check the Jacobians produced by a factor against finite differences.
static double TestFunction(double x)
void insert(Key j, const Value &val)
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
Parameters parameters() const
Return Fourier coefficients.
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
std::uint64_t Key
Integer nonlinear key type.
Fit a Basis using least-squares.