32 using namespace gtsam;
42 static const int N = 5;
43 auto points = Chebyshev2::Points(N);
45 expected << -1., -
sqrt(2.) / 2., 0.,
sqrt(2.) / 2., 1.;
46 static const double tol = 1
e-15;
60 static const int N = 5;
61 auto points = Chebyshev2::Points(N, 0, 20);
63 expected << 0., 1. -
sqrt(2.) / 2., 1., 1. +
sqrt(2.) / 2., 2.;
65 static const double tol = 1
e-15;
73 Vector actual = Chebyshev2::Points(N, 0, 20);
81 Chebyshev2::EvaluationFunctor
fx(N, 0.5);
90 Chebyshev2::EvaluationFunctor
fx(3, 1.5, 0, 2);
99 Chebyshev2::EvaluationFunctor
fx(5, 0.5);
108 double t = 30,
a = 0,
b = 100;
112 X.row(0) = Chebyshev2::Points(N,
a,
b);
119 Chebyshev2::VectorEvaluationFunctor
fx(2, N, t,
a,
b);
123 std::function<Vector2(Matrix)>
f =
124 std::bind(&Chebyshev2::VectorEvaluationFunctor::operator(), fx,
125 std::placeholders::_1,
nullptr);
127 numericalDerivative11<Vector2, Matrix, 2 * N>(
f,
X);
134 double t = 30,
a = 0,
b = 100;
137 X.row(0) = Chebyshev2::Points(
N,
a,
b);
138 X.row(1) = Vector::Zero(
N);
139 X.row(2) = 0.1 * Vector::Ones(
N);
145 Chebyshev2::ManifoldEvaluationFunctor<Pose2>
fx(
N, t,
a,
b);
151 std::function<Pose2(Matrix)>
f =
152 std::bind(&Chebyshev2::ManifoldEvaluationFunctor<Pose2>::operator(), fx,
153 std::placeholders::_1,
nullptr);
155 numericalDerivative11<Pose2, Matrix, 3 * N>(
f,
X);
159 #ifdef GTSAM_POSE3_EXPMAP 163 double a = 10,
b = 100;
164 double t = Chebyshev2::Points(
N, a,
b)(11);
166 Rot3 R = Rot3::Ypr(-2.21366492
e-05, -9.35353636
e-03, -5.90463598
e-04);
169 Vector6
xi = Pose3::ChartAtOrigin::Local(pose);
175 Chebyshev2::ManifoldEvaluationFunctor<Pose3>
fx(
N, t, a,
b);
181 std::function<Pose3(Matrix)>
f =
182 std::bind(&Chebyshev2::ManifoldEvaluationFunctor<Pose3>::operator(), fx,
183 std::placeholders::_1,
nullptr);
185 numericalDerivative11<Pose3, Matrix, 6 * N>(
f,
X);
194 for (
size_t i = 0;
i < 16;
i++) {
195 double x = (1.0 / 16) *
i - 0.99,
y = x;
204 expected << -1, 0, 1;
214 expected << 1.5000, -2.0000, 0.5000,
215 0.5000, -0.0000, -0.5000,
216 -0.5000, 2.0000, -1.5000;
221 Matrix actual = Chebyshev2::DifferentiationMatrix(N);
230 expected << 8.5000, -10.4721, 2.8944, -1.5279, 1.1056, -0.5000,
231 2.6180, -1.1708, -2.0000, 0.8944, -0.6180, 0.2764,
232 -0.7236, 2.0000, -0.1708, -1.6180, 0.8944, -0.3820,
233 0.3820, -0.8944, 1.6180, 0.1708, -2.0000, 0.7236,
234 -0.2764, 0.6180, -0.8944, 2.0000, 1.1708, -2.6180,
235 0.5000, -1.1056, 1.5279, -2.8944, 10.4721, -8.5000;
240 Matrix actual = Chebyshev2::DifferentiationMatrix(N);
247 return 3.0 *
pow(x, 3) - 2.0 *
pow(x, 2) + 5.0 * x - 11;
253 return 9.0 *
pow(x, 2) - 4.0 * x + 5.0;
259 for (
size_t i = 0;
i <
N;
i++) {
260 fvals(
i) =
f(Chebyshev2::Point(N,
i));
262 double x1 = 0.7,
x2 = -0.376;
270 double a = 0,
b = 10,
x1 = 7,
x2 = 4.12;
273 for (
size_t i = 0;
i <
N;
i++) {
274 fvals(
i) =
f(Chebyshev2::Point(N,
i, a,
b));
281 double expected2 =
f(
x2);
282 double actual2 = weights2 * fvals;
288 for (
size_t i = 0;
i <
N;
i++) {
289 fvals(
i) =
f(Chebyshev2::Point(N,
i));
291 double x1 = 0.7,
x2 = -0.376,
x3 = 0.0;
292 Weights dWeights1 = Chebyshev2::DerivativeWeights(N, x1);
295 Weights dWeights2 = Chebyshev2::DerivativeWeights(N,
x2);
298 Weights dWeights3 = Chebyshev2::DerivativeWeights(N,
x3);
302 double x4 = Chebyshev2::Point(N, 3);
303 Weights dWeights4 = Chebyshev2::DerivativeWeights(N, x4);
308 double x1 = 5,
x2 = 4.12,
a = 0,
b = 10;
311 for (
size_t i = 0;
i <
N;
i++) {
312 fvals(
i) =
f(Chebyshev2::Point(N,
i,
a,
b));
315 Weights dWeights1 = Chebyshev2::DerivativeWeights(N, x1,
a,
b);
318 Weights dWeights2 = Chebyshev2::DerivativeWeights(N,
x2,
a,
b);
322 double x3 = Chebyshev2::Point(N, 3,
a,
b);
323 Weights dWeights3 = Chebyshev2::DerivativeWeights(N, x3,
a,
b);
332 Matrix D6 = Chebyshev2::DifferentiationMatrix(N6);
334 Weights actual = Chebyshev2::DerivativeWeights(N6, x1);
337 double a = -3,
b = 8,
x2 = 5.05;
338 Matrix D6_2 = Chebyshev2::DifferentiationMatrix(N6, a,
b);
339 Weights expected1 = Chebyshev2::CalculateWeights(N6,
x2, a,
b) * D6_2;
340 Weights actual1 = Chebyshev2::DerivativeWeights(N6,
x2, a,
b);
348 Matrix D6 = Chebyshev2::DifferentiationMatrix(N6);
357 Matrix D7 = Chebyshev2::DifferentiationMatrix(N7);
373 const double x = 0.2;
374 Matrix numeric_dTdx = numericalDerivative11<double, double>(
proxy3,
x);
377 Matrix D6 = Chebyshev2::DifferentiationMatrix(6);
379 Chebyshev2::EvaluationFunctor
fx(6, x);
383 Chebyshev2::DerivativeFunctor dfdx(6, x);
390 return Chebyshev2::EvaluationFunctor(6, x, 0, 3)(
f3_at_6points);
397 const double x = 0.2;
398 Matrix numeric_dTdx = numericalDerivative11<double, double>(
proxy4,
x);
401 Matrix D6 = Chebyshev2::DifferentiationMatrix(6, 0, 3);
403 Chebyshev2::EvaluationFunctor
fx(6, x, 0, 3);
407 Chebyshev2::DerivativeFunctor dfdx(6, x, 0, 3);
414 const size_t N = 3,
M = 2;
415 const double x = 0.2;
416 using VecD = Chebyshev2::VectorDerivativeFunctor;
417 VecD
fx(
M, N, x, 0, 3);
423 Matrix expectedH = numericalDerivative11<Vector2, Matrix, M * N>(
424 std::bind(&VecD::operator(), fx, std::placeholders::_1,
nullptr),
X);
431 const size_t N = 64,
M = 1,
T = 15;
432 using VecD = Chebyshev2::VectorDerivativeFunctor;
434 const Vector points = Chebyshev2::Points(N, 0,
T);
438 for (
size_t i = 0;
i <
N; ++
i) {
444 for (
size_t i = 0;
i <
N; ++
i) {
445 VecD
d(
M, N, points(
i), 0,
T);
452 VecD vecd(
M, N, points(0), 0,
T);
454 Matrix expectedH = numericalDerivative11<Vector1, Matrix, M * N>(
455 std::bind(&VecD::operator(), vecd, std::placeholders::_1,
nullptr),
X);
462 const size_t N = 6,
M = 2;
463 const double x = 0.2;
464 using CompFunc = Chebyshev2::ComponentDerivativeFunctor;
466 CompFunc
fx(
M, N, row, x, 0, 3);
471 Matrix expectedH = numericalDerivative11<double, Matrix, M * N>(
472 std::bind(&CompFunc::operator(), fx, std::placeholders::_1,
nullptr),
X);
479 Vector actual = Chebyshev2::IntegrationWeights(N7);
481 0.457142857142857, 0.520634920634921, 0.457142857142857,
482 0.253968253968254, 0.0285714285714286)
487 Vector actual2 = Chebyshev2::IntegrationWeights(N8);
488 Vector expected2 = (
Vector(N8) << 0.0204081632653061, 0.190141007218208,
489 0.352242423718159, 0.437208405798326, 0.437208405798326,
490 0.352242423718159, 0.190141007218208, 0.0204081632653061)
Matrix< RealScalar, Dynamic, Dynamic > M
Concept check for values that can be used in unit tests.
static int runAllTests(TestResult &result)
noiseModel::Diagonal::shared_ptr model
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Rot2 R(Rot2::fromAngle(0.1))
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
vector< double > weights1
Evaluate derivatives of a nonlinear factor numerically.
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
#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)
#define EXPECT(condition)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Pseudo-spectral parameterization for Chebyshev polynomials of the second kind.
Pose3 x3(Rot3::Ypr(M_PI/4.0, 0.0, 0.0), l2)
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
vector< double > weights2
Jet< T, N > sqrt(const Jet< T, N > &f)
Jet< T, N > pow(const Jet< T, N > &f, double g)
The matrix class, also used for vectors and row-vectors.
std::shared_ptr< Diagonal > shared_ptr
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
Fit a Basis using least-squares.