testLieMatrix.cpp
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 
19 #include <gtsam/base/Testable.h>
20 #include <gtsam/base/Manifold.h>
21 
22 using namespace gtsam;
23 
26 
27 /* ************************************************************************* */
28 TEST( LieMatrix, construction ) {
29  Matrix m = (Matrix(2,2) << 1.0,2.0, 3.0,4.0).finished();
30  LieMatrix lie1(m), lie2(m);
31 
33  EXPECT(assert_equal(m, lie1.matrix()));
34  EXPECT(assert_equal(lie1, lie2));
35 }
36 
37 /* ************************************************************************* */
38 TEST( LieMatrix, other_constructors ) {
39  Matrix init = (Matrix(2,2) << 10.0,20.0, 30.0,40.0).finished();
40  LieMatrix exp(init);
41  double data[] = {10,30,20,40};
42  LieMatrix b(2,2,data);
43  EXPECT(assert_equal(exp, b));
44 }
45 
46 /* ************************************************************************* */
47 TEST(LieMatrix, retract) {
48  LieMatrix init((Matrix(2,2) << 1.0,2.0,3.0,4.0).finished());
49  Vector update = (Vector(4) << 3.0, 4.0, 6.0, 7.0).finished();
50 
51  LieMatrix expected((Matrix(2,2) << 4.0, 6.0, 9.0, 11.0).finished());
52  LieMatrix actual = traits<LieMatrix>::Retract(init,update);
53 
54  EXPECT(assert_equal(expected, actual));
55 
56  Vector expectedUpdate = update;
57  Vector actualUpdate = traits<LieMatrix>::Local(init,actual);
58 
59  EXPECT(assert_equal(expectedUpdate, actualUpdate));
60 
61  Vector expectedLogmap = (Vector(4) << 1, 2, 3, 4).finished();
62  Vector actualLogmap = traits<LieMatrix>::Logmap(LieMatrix((Matrix(2,2) << 1.0, 2.0, 3.0, 4.0).finished()));
63  EXPECT(assert_equal(expectedLogmap, actualLogmap));
64 }
65 
66 /* ************************************************************************* */
67 int main() { TestResult tr; return TestRegistry::runAllTests(tr); }
68 /* ************************************************************************* */
69 
70 
Matrix3f m
Concept check for values that can be used in unit tests.
def update(text)
Definition: relicense.py:46
static int runAllTests(TestResult &result)
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
Matrix expected
Definition: testMatrix.cpp:974
int main()
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:43
#define GTSAM_CONCEPT_LIE_INST(T)
Definition: Lie.h:355
Eigen::VectorXd Vector
Definition: Vector.h:38
Base class and basic functions for Manifold types.
#define EXPECT(condition)
Definition: Test.h:151
int data[]
const G & b
Definition: Group.h:83
traits
Definition: chartTesting.h:28
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:42
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
Definition: pybind11.h:1460
TEST(LPInitSolver, InfiniteLoopSingleVar)
#define GTSAM_CONCEPT_TESTABLE_INST(T)
Definition: Testable.h:174


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:47:47