diff --git a/.cproject b/.cproject index 84dece771..6adea9f16 100644 --- a/.cproject +++ b/.cproject @@ -390,12 +390,19 @@ make - testErrors.run true false true + + make + -j2 + tests/testLieScalar.run + true + true + true + make -j2 @@ -510,7 +517,6 @@ make - testBayesTree.run true false @@ -518,7 +524,6 @@ make - testBinaryBayesNet.run true false @@ -566,7 +571,6 @@ make - testSymbolicBayesNet.run true false @@ -574,7 +578,6 @@ make - testSymbolicFactor.run true false @@ -582,7 +585,6 @@ make - testSymbolicFactorGraph.run true false @@ -662,6 +664,7 @@ make + testGraph.run true false @@ -757,6 +760,7 @@ make + testInference.run true false @@ -764,6 +768,7 @@ make + testGaussianBayesNet.run true false @@ -771,6 +776,7 @@ make + testGaussianFactor.run true false @@ -778,6 +784,7 @@ make + testJunctionTree.run true false @@ -785,6 +792,7 @@ make + testSymbolicBayesNet.run true false @@ -792,6 +800,7 @@ make + testSymbolicFactorGraph.run true false @@ -1007,6 +1016,7 @@ make + testSimulated2DOriented.run true false @@ -1046,6 +1056,7 @@ make + testSimulated2D.run true false @@ -1053,6 +1064,7 @@ make + testSimulated3D.run true false @@ -1138,6 +1150,46 @@ true true + + make + -j2 + install + true + true + true + + + make + -j2 + clean + true + true + true + + + make + -j2 + check + true + true + true + + + make + -j2 + all + true + true + true + + + make + -j2 + dist + true + true + true + make -j2 @@ -1234,46 +1286,6 @@ true true - - make - -j2 - install - true - true - true - - - make - -j2 - clean - true - true - true - - - make - -j2 - check - true - true - true - - - make - -j2 - all - true - true - true - - - make - -j2 - dist - true - true - true - make -j2 diff --git a/base/LieScalar.h b/base/LieScalar.h new file mode 100644 index 000000000..79c716f7f --- /dev/null +++ b/base/LieScalar.h @@ -0,0 +1,64 @@ +/** + * @file LieScalar.h + * @brief A wrapper around scalar providing Lie compatibility + * @author Kai Ni + */ + +#pragma once + +#include +#include + +namespace gtsam { + + /** + * LieScalar is a wrapper around double to allow it to be a Lie type + */ + struct LieScalar : public Lie, Testable { + + /** default constructor - should be unnecessary */ + LieScalar() {} + + /** wrap a double */ + LieScalar(double d) : d_(d) {} + + /** print @param s optional string naming the object */ + inline void print(const std::string& name="") const { + std::cout << name << ": " << d_ << std::endl; + } + + /** equality up to tolerance */ + inline bool equals(const LieScalar& expected, double tol=1e-5) const { + return fabs(expected.d_ - d_) <= tol; + } + + /** + * Returns dimensionality of the tangent space + */ + inline size_t dim() const { return 1; } + + /** + * Returns Exponential map update of T + * Default implementation calls global binary function + */ + inline LieScalar expmap(const Vector& v) const { return LieScalar(d_ + v(0)); } + + /** expmap around identity */ + static inline LieScalar Expmap(const Vector& v) { return LieScalar(v(0)); } + + /** + * Returns Log map + * Default Implementation calls global binary function + */ + inline Vector logmap(const LieScalar& lp) const { + return Vector_(1, lp.d_ - d_); + } + + /** Logmap around identity - just returns with default cast back */ + static inline Vector Logmap(const LieScalar& p) { return Vector_(1, p.d_); } + + + private: + double d_; + }; +} // \namespace gtsam diff --git a/base/Makefile.am b/base/Makefile.am index 32d814d93..e5f2a65a0 100644 --- a/base/Makefile.am +++ b/base/Makefile.am @@ -26,9 +26,9 @@ endif headers += Testable.h TestableAssertions.h numericalDerivative.h # Lie Groups -headers += Lie.h Lie-inl.h lieProxies.h +headers += Lie.h Lie-inl.h lieProxies.h LieScalar.h sources += LieVector.cpp -check_PROGRAMS += tests/testLieVector +check_PROGRAMS += tests/testLieVector tests/testLieScalar # Data structures headers += BTree.h DSF.h diff --git a/base/tests/testLieScalar.cpp b/base/tests/testLieScalar.cpp new file mode 100644 index 000000000..c845a978a --- /dev/null +++ b/base/tests/testLieScalar.cpp @@ -0,0 +1,30 @@ +/** + * @file testLieScalar.cpp + * @author Kai Ni + */ + +#include + +#include + +using namespace gtsam; + +/* ************************************************************************* */ +TEST( testLieScalar, construction ) { + double d = 2.; + LieScalar lie1(d), lie2(d); + + EXPECT(lie1.dim() == 1); + EXPECT(assert_equal(lie1, lie2)); +} + +/* ************************************************************************* */ +TEST( testLieScalar, logmap ) { + LieScalar lie1(1.), lie2(3.); + + EXPECT(assert_equal(Vector_(1, 2.), lie1.logmap(lie2))); +} + +/* ************************************************************************* */ +int main() { TestResult tr; return TestRegistry::runAllTests(tr); } +/* ************************************************************************* */