From ed1f5f75762a650a9181519d407cb9aebf1ef9c7 Mon Sep 17 00:00:00 2001 From: Duy-Nguyen Ta Date: Fri, 12 Apr 2013 15:43:36 +0000 Subject: [PATCH] add cpp file for LieScalar. Try to debug the "same-name-different-type" problem in matlab wrapper. --- gtsam/base/LieScalar.cpp | 17 +++++++++++++++++ gtsam/base/LieScalar.h | 26 ++++++++++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 gtsam/base/LieScalar.cpp diff --git a/gtsam/base/LieScalar.cpp b/gtsam/base/LieScalar.cpp new file mode 100644 index 000000000..5f59c29bc --- /dev/null +++ b/gtsam/base/LieScalar.cpp @@ -0,0 +1,17 @@ +/* + * LieScalar.cpp + * + * Created on: Apr 12, 2013 + * Author: thduynguyen + */ + + + + +#include + +namespace gtsam { + void LieScalar::print(const std::string& name) const { + std::cout << name << ": " << d_ << std::endl; + } +} diff --git a/gtsam/base/LieScalar.h b/gtsam/base/LieScalar.h index dc8f29645..29967dd3f 100644 --- a/gtsam/base/LieScalar.h +++ b/gtsam/base/LieScalar.h @@ -40,41 +40,39 @@ namespace gtsam { operator double() const { return d_; } /** print @param name optional string naming the object */ - inline void print(const std::string& name="") const { - std::cout << name << ": " << d_ << std::endl; - } + void print(const std::string& name="") const; /** equality up to tolerance */ - inline bool equals(const LieScalar& expected, double tol=1e-5) const { + bool equals(const LieScalar& expected, double tol=1e-5) const { return fabs(expected.d_ - d_) <= tol; } // Manifold requirements /** Returns dimensionality of the tangent space */ - inline size_t dim() const { return 1; } - inline static size_t Dim() { return 1; } + size_t dim() const { return 1; } + static size_t Dim() { return 1; } /** Update the LieScalar with a tangent space update */ - inline LieScalar retract(const Vector& v) const { return LieScalar(value() + v(0)); } + LieScalar retract(const Vector& v) const { return LieScalar(value() + v(0)); } /** @return the local coordinates of another object */ - inline Vector localCoordinates(const LieScalar& t2) const { return Vector_(1,(t2.value() - value())); } + Vector localCoordinates(const LieScalar& t2) const { return Vector_(1,(t2.value() - value())); } // Group requirements /** identity */ - inline static LieScalar identity() { + static LieScalar identity() { return LieScalar(); } /** compose with another object */ - inline LieScalar compose(const LieScalar& p) const { + LieScalar compose(const LieScalar& p) const { return LieScalar(d_ + p.d_); } /** between operation */ - inline LieScalar between(const LieScalar& l2, + LieScalar between(const LieScalar& l2, boost::optional H1=boost::none, boost::optional H2=boost::none) const { if(H1) *H1 = -eye(1); @@ -83,17 +81,17 @@ namespace gtsam { } /** invert the object and yield a new one */ - inline LieScalar inverse() const { + LieScalar inverse() const { return LieScalar(-1.0 * value()); } // Lie functions /** Expmap around identity */ - static inline LieScalar Expmap(const Vector& v) { return LieScalar(v(0)); } + static LieScalar Expmap(const Vector& v) { return LieScalar(v(0)); } /** Logmap around identity - just returns with default cast back */ - static inline Vector Logmap(const LieScalar& p) { return Vector_(1,p.value()); } + static Vector Logmap(const LieScalar& p) { return Vector_(1,p.value()); } private: double d_;