deprecated/LieMatrix.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 <cstdarg>
21 
22 #include <gtsam/base/VectorSpace.h>
23 #include <boost/serialization/nvp.hpp>
24 
25 namespace gtsam {
26 
32 struct LieMatrix : public Matrix {
33 
37 
39  LieMatrix() {}
40 
42  LieMatrix(const Matrix& v) : Matrix(v) {}
43 
44  template <class M>
45  LieMatrix(const M& v) : Matrix(v) {}
46 
47 // Currently TMP constructor causes ICE on MSVS 2013
48 #if (_MSC_VER < 1800)
49 
50  template<int M, int N>
52 #endif
53 
55  LieMatrix(size_t m, size_t n, const double* const data) :
56  Matrix(Eigen::Map<const Matrix>(data, m, n)) {}
57 
61 
63  void print(const std::string& name = "") const {
65  }
67  inline bool equals(const LieMatrix& expected, double tol=1e-5) const {
68  return gtsam::equal_with_abs_tol(matrix(), expected.matrix(), tol);
69  }
70 
74 
76  inline Matrix matrix() const {
77  return static_cast<Matrix>(*this);
78  }
79 
81 
84  LieMatrix compose(const LieMatrix& q) { return (*this)+q;}
85  LieMatrix between(const LieMatrix& q) { return q-(*this);}
86  LieMatrix inverse() { return -(*this);}
88 
91  Vector localCoordinates(const LieMatrix& q) { return between(q).vector();}
92  LieMatrix retract(const Vector& v) {return compose(LieMatrix(v));}
94 
97  static Vector Logmap(const LieMatrix& p) {return p.vector();}
98  static LieMatrix Expmap(const Vector& v) { return LieMatrix(v);}
100 
103 
105  inline size_t dim() const { return size(); }
106 
108  inline Vector vector() const {
109  Vector result(size());
112  Eigen::Map<RowMajor>(&result(0), rows(), cols()) = *this;
113  return result;
114  }
115 
117  inline static LieMatrix identity() {
118  throw std::runtime_error("LieMatrix::identity(): Don't use this function");
119  return LieMatrix();
120  }
122 
123 private:
124 
125  // Serialization function
127  template<class Archive>
128  void serialize(Archive & ar, const unsigned int /*version*/) {
129  ar & boost::serialization::make_nvp("Matrix",
130  boost::serialization::base_object<Matrix>(*this));
131 
132  }
133 
134 };
135 
136 
137 template<>
138 struct traits<LieMatrix> : public internal::VectorSpace<LieMatrix> {
139 
140  // Override Retract, as the default version does not know how to initialize
142  ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
143  if (H1) *H1 = Eye(origin);
144  if (H2) *H2 = Eye(origin);
145  typedef const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic,
147  return origin + Eigen::Map<RowMajor>(&v(0), origin.rows(), origin.cols());
148  }
149 
150 };
151 
152 } // \namespace gtsam
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
Matrix3f m
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:38
LieMatrix(size_t m, size_t n, const double *const data)
Vector vector() const
LieMatrix between(const LieMatrix &q)
void print(const std::string &name="") const
VectorSpace provides both Testable and VectorSpaceTraits.
Definition: VectorSpace.h:207
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 y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set origin
static LieMatrix Expmap(const Vector &v)
Matrix expected
Definition: testMatrix.cpp:974
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:94
LieMatrix(const Matrix &v)
ArrayXcf v
Definition: Cwise_arg.cpp:1
int n
void serialize(Archive &ar, const unsigned int)
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:43
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
LieMatrix retract(const Vector &v)
Matrix matrix() const
Vector localCoordinates(const LieMatrix &q)
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
static LieMatrix Retract(const LieMatrix &origin, const TangentVector &v, ChartJacobian H1=boost::none, ChartJacobian H2=boost::none)
Eigen::VectorXd Vector
Definition: Vector.h:38
Values result
bool equals(const LieMatrix &expected, double tol=1e-5) const
int data[]
LieMatrix(const Eigen::Matrix< double, M, N > &v)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EIGEN_DEVICE_FUNC const Scalar & q
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
Definition: base/Matrix.h:84
traits
Definition: chartTesting.h:28
static Vector Logmap(const LieMatrix &p)
float * p
Annotation for function names.
Definition: attr.h:36
const G double tol
Definition: Group.h:83
const int Dynamic
Definition: Constants.h:21
The matrix class, also used for vectors and row-vectors.
friend class boost::serialization::access
LieMatrix compose(const LieMatrix &q)
static LieMatrix identity()


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