gtsam  3.2.1
gtsam
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LieScalar.h
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 
18 #pragma once
19 
20 #include <gtsam/dllexport.h>
21 #include <gtsam/base/DerivedValue.h>
22 #include <gtsam/base/Lie.h>
23 
24 namespace gtsam {
25 
29  struct GTSAM_EXPORT LieScalar : public DerivedValue<LieScalar> {
30 
32  LieScalar() : d_(0.0) {}
33 
35  explicit LieScalar(double d) : d_(d) {}
36 
38  double value() const { return d_; }
39 
41  operator double() const { return d_; }
42 
44  void print(const std::string& name="") const;
45 
47  bool equals(const LieScalar& expected, double tol=1e-5) const {
48  return fabs(expected.d_ - d_) <= tol;
49  }
50 
51  // Manifold requirements
52 
54  size_t dim() const { return 1; }
55  static size_t Dim() { return 1; }
56 
58  LieScalar retract(const Vector& v) const { return LieScalar(value() + v(0)); }
59 
61  Vector localCoordinates(const LieScalar& t2) const { return (Vector(1) << (t2.value() - value())); }
62 
63  // Group requirements
64 
66  static LieScalar identity() {
67  return LieScalar();
68  }
69 
72  boost::optional<Matrix&> H1=boost::none,
73  boost::optional<Matrix&> H2=boost::none) const {
74  if(H1) *H1 = eye(1);
75  if(H2) *H2 = eye(1);
76  return LieScalar(d_ + p.d_);
77  }
78 
81  boost::optional<Matrix&> H1=boost::none,
82  boost::optional<Matrix&> H2=boost::none) const {
83  if(H1) *H1 = -eye(1);
84  if(H2) *H2 = eye(1);
85  return LieScalar(l2.value() - value());
86  }
87 
89  LieScalar inverse() const {
90  return LieScalar(-1.0 * value());
91  }
92 
93  // Lie functions
94 
96  static LieScalar Expmap(const Vector& v) { return LieScalar(v(0)); }
97 
99  static Vector Logmap(const LieScalar& p) { return (Vector(1) << p.value()); }
100 
102  static Matrix dexpL(const Vector& v) {
103  return eye(1);
104  }
105 
107  static Matrix dexpInvL(const Vector& v) {
108  return eye(1);
109  }
110 
111  private:
112  double d_;
113  };
114 } // \namespace gtsam
LieScalar inverse() const
invert the object and yield a new one
Definition: LieScalar.h:89
Vector localCoordinates(const LieScalar &t2) const
Definition: LieScalar.h:61
Base class and basic functions for Lie types.
LieScalar is a wrapper around double to allow it to be a Lie type.
Definition: LieScalar.h:29
Matrix eye(size_t m, size_t n)
Creates an identity matrix, with matlab-like syntax.
Definition: Matrix.cpp:50
bool equals(const LieScalar &expected, double tol=1e-5) const
equality up to tolerance
Definition: LieScalar.h:47
LieScalar compose(const LieScalar &p, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
compose with another object
Definition: LieScalar.h:71
static Matrix dexpInvL(const Vector &v)
Left-trivialized derivative inverse of the exponential map.
Definition: LieScalar.h:107
double value() const
access the underlying value
Definition: LieScalar.h:38
static LieScalar identity()
identity
Definition: LieScalar.h:66
LieScalar between(const LieScalar &l2, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
between operation
Definition: LieScalar.h:80
LieScalar()
default constructor
Definition: LieScalar.h:32
void print(const Matrix &A, const string &s, ostream &stream)
print a matrix
Definition: Matrix.cpp:183
static LieScalar Expmap(const Vector &v)
Expmap around identity.
Definition: LieScalar.h:96
LieScalar retract(const Vector &v) const
Update the LieScalar with a tangent space update.
Definition: LieScalar.h:58
static Matrix dexpL(const Vector &v)
Left-trivialized derivative of the exponential map.
Definition: LieScalar.h:102
static Vector Logmap(const LieScalar &p)
Logmap around identity - just returns with default cast back.
Definition: LieScalar.h:99
LieScalar(double d)
wrap a double
Definition: LieScalar.h:35
Definition: DerivedValue.h:44
size_t dim() const
Returns dimensionality of the tangent space.
Definition: LieScalar.h:54