26 using namespace gtsam;
29 auto model = noiseModel::Unit::Create(1);
34 TEST(Chebyshev, Chebyshev1) {
35 using Synth = Chebyshev1Basis::EvaluationFunctor;
49 using Synth = Chebyshev2Basis::EvaluationFunctor;
62 TEST(Chebyshev, Evaluation) {
63 Chebyshev1Basis::EvaluationFunctor
fx(
N, 0.5);
81 t << -0.7, -0.4, 0.1, 0.3, 0.7, 0.9;
83 x << -0.7, -0.4, 0.1, 0.3, 0.7, 0.9;
85 for (
size_t i = 0;
i <
m;
i++) {
111 Chebyshev1Basis::EvaluationFunctor
f(
N, 1.0);
113 double actual =
f(actual_c, H);
117 double actual_variance_on_prediction = (H * cov * H.transpose())(0);
122 TEST(Chebyshev, Decomposition) {
127 for (
size_t i = 0;
i <
M;
i++) {
128 double x = ((double)
i / M);
150 D = Chebyshev1Basis::DerivativeWeights(
N, x);
155 D = Chebyshev1Basis::DerivativeWeights(
N, x);
160 D = Chebyshev1Basis::DerivativeWeights(
N, x);
169 return Chebyshev1Basis::EvaluationFunctor(N, x)(
Vector(
f));
172 TEST(Chebyshev1, Derivative2) {
173 const double x = 0.5;
174 auto D = Chebyshev1Basis::DerivativeWeights(
N, x);
177 numericalDerivative21<double, double, double>(
proxy1,
x,
N);
191 CHECK_EXCEPTION(Chebyshev2Basis::DerivativeWeights(
N, x), std::runtime_error);
193 CHECK_EXCEPTION(Chebyshev2Basis::DerivativeWeights(
N, x), std::runtime_error);
196 D = Chebyshev2Basis::DerivativeWeights(
N, x);
201 D = Chebyshev2Basis::DerivativeWeights(
N, x);
206 D = Chebyshev2Basis::DerivativeWeights(
N, x);
211 D = Chebyshev2Basis::DerivativeWeights(
N, x, 0, 20);
218 return Chebyshev2Basis::EvaluationFunctor(N, x)(
Vector(
f));
222 const double x = 0.5;
223 auto D = Chebyshev2Basis::DerivativeWeights(
N, x);
226 numericalDerivative21<double, double, double>(
proxy2,
x,
N);
const gtsam::Symbol key('X', 0)
double proxy1(double x, size_t N)
Matrix marginalCovariance(Key variable) const
Matrix< RealScalar, Dynamic, Dynamic > M
virtual const Values & optimize()
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)
noiseModel::Diagonal::shared_ptr model
const ValueType at(Key j) const
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Chebyshev basis decompositions.
Evaluate derivatives of a nonlinear factor numerically.
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
#define CHECK_EXCEPTION(condition, exception_name)
NonlinearFactorGraph graph
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
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.)
double proxy2(double x, size_t N)
static ConjugateGradientParameters parameters
A class for computing marginals in a NonlinearFactorGraph.
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.
Marginals marginals(graph, result)
Fit a Basis using least-squares.
TEST(Chebyshev, Chebyshev1)