00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef EIGEN_LGSM_LIE_ALGEBRA_H
00011 #define EIGEN_LGSM_LIE_ALGEBRA_H
00012
00013
00014
00015
00016
00029 namespace internal {
00030 template<class A, class Derived>
00031 struct traits<LieAlgebraBase<A, Derived> > : public traits<A> {};
00032 }
00033
00034 template<class A, class Derived> class LieAlgebraBase : public MatrixBase<Derived> {
00035 protected:
00037 typedef MatrixBase<Derived> Base;
00038 public:
00039
00040 EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebraBase)
00041
00042 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(LieAlgebraBase)
00043
00044 LIE_INHERIT_MATRIX_BASE(A::RowsAtCompileTime, A::ColsAtCompileTime)
00045
00047 typedef A BaseType;
00049 typedef typename internal::traits<Derived>::Coefficients Coefficients;
00051 typedef LieAlgebra<BaseType> PlainObject;
00053 typedef LieAlgebraDual<BaseType> AlgebraDual;
00055 typedef typename Derived::LieGroup Group;
00056
00057
00059 template<class OtherDerived> inline PlainObject bracket(const LieAlgebraBase<BaseType, OtherDerived>& a) const;
00061 template<class OtherDerived> inline const PlainObject adjoint(const LieAlgebraBase<BaseType, OtherDerived>& a) const;
00062
00065 Group exp(Scalar precision = 1.e-6) const;
00066
00068 inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
00070 inline Derived& derived() { return *static_cast<Derived*>(this); }
00071
00073 inline Coefficients& get();
00075 inline const Coefficients& get() const;
00076 };
00077
00078
00079
00080
00081
00094 namespace internal {
00095 template<class A, class Derived>
00096 struct traits<LieAlgebraDualBase<A, Derived> > : public traits<A> {};
00097 }
00098
00099 template<class A, class Derived> class LieAlgebraDualBase : public MatrixBase<Derived > {
00100 protected:
00102 typedef MatrixBase<Derived> Base;
00103 public:
00104
00105 EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebraDualBase)
00106
00107
00108
00109 LIE_INHERIT_MATRIX_BASE(A::RowsAtCompileTime, A::ColsAtCompileTime)
00110
00111
00113 EIGEN_STRONG_INLINE LieAlgebraDualBase& operator=(const LieAlgebraDualBase& other) {
00114 this->get() = other.get();
00115 return *this;
00116 }
00118 template<class BaseType, class OtherDerived> EIGEN_STRONG_INLINE Derived& operator=(const LieAlgebraDualBase<BaseType, OtherDerived>& other) {
00119 this->get() = other.get();
00120 return derived();
00121 }
00122
00124 typedef A BaseType;
00126 typedef typename internal::traits<Derived>::Coefficients Coefficients;
00128 typedef LieAlgebraDual<BaseType> PlainObject;
00130 typedef LieAlgebra<BaseType> Algebra;
00132 typedef typename internal::traits<Derived>::Group Group;
00133
00135 inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
00137 inline Derived& derived() { return *static_cast<Derived*>(this); }
00138
00140 inline Coefficients& get() {return this->derived().get(); }
00142 inline const Coefficients& get() const {return this->derived().get(); }
00143 };
00144
00145
00146
00147
00148
00149
00150 namespace internal {
00151 template<class A>
00152 struct traits<LieAlgebra<A> > : public traits<LieAlgebraBase<A, LieAlgebra<A> > >
00153 {
00154 typedef A Coefficients;
00155 };
00156 }
00157
00168 template<class A> class LieAlgebra : public LieAlgebraBase<A, LieAlgebra<A> > {
00169 protected:
00171 typedef LieAlgebraBase<A, LieAlgebra<A> > Base;
00172 public:
00173
00174 EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebra)
00175
00176 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(LieAlgebra)
00177
00179 typedef typename internal::traits<LieAlgebra<A> >::Coefficients Coefficients;
00180
00182 inline LieAlgebra(const LieAlgebra&);
00183
00185 inline Coefficients& get() { return m_coeffs; }
00187 inline const Coefficients& get() const { return m_coeffs; }
00188
00189 protected:
00191 Coefficients m_coeffs;
00192 };
00193
00194
00195
00196
00197
00198 namespace internal {
00199 template<class A>
00200 struct traits<LieAlgebraDual<A> > : public traits<LieAlgebraDualBase<A, LieAlgebraDual<A> > >
00201 {
00202 typedef A Coefficients;
00203 };
00204 }
00205
00216 template<class A> class LieAlgebraDual : public LieAlgebraDualBase<A, LieAlgebraDual<A> > {
00217 protected:
00218 typedef LieAlgebraDualBase<A, LieAlgebraDual<A> > Base;
00220 public:
00221
00222 EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebraDual)
00223
00224 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(LieAlgebraDual)
00225
00227 typedef typename internal::traits<LieAlgebraDual<A> >::Coefficients Coefficients;
00228
00230 inline LieAlgebraDual(const LieAlgebraDual&);
00231
00233 inline Coefficients& get() { return m_coeffs; }
00235 inline const Coefficients& get() const { return m_coeffs; }
00236 protected:
00238 Coefficients m_coeffs;
00239 };
00240
00241
00242
00243
00244
00245
00246 namespace internal {
00247 template<class A, int MapOptions, typename StrideType>
00248 struct traits<Map<LieAlgebra<A>, MapOptions, StrideType> > : public traits<LieAlgebraBase<A, Map<LieAlgebra<A>, MapOptions, StrideType> > >
00249 {
00250 typedef Map<A, MapOptions, StrideType> Coefficients;
00251 };
00252 }
00253
00254 namespace internal {
00255 template<class A, int MapOptions, typename StrideType>
00256 struct traits<Map<const LieAlgebra<A>, MapOptions, StrideType> > : public traits<LieAlgebraBase<A, Map<const LieAlgebra<A>, MapOptions, StrideType> > >
00257 {
00258 typedef Map<const A, MapOptions, StrideType> Coefficients;
00259 };
00260 }
00261
00276 template<class A, int MapOptions, typename StrideType>
00277 class Map<LieAlgebra<A>, MapOptions, StrideType> : public LieAlgebraBase<A, Map<LieAlgebra<A>, MapOptions, StrideType> > {
00278 protected:
00280 typedef LieAlgebraBase<A, Map<LieAlgebra<A>, MapOptions, StrideType> > Base;
00281 public:
00282
00283 EIGEN_DENSE_PUBLIC_INTERFACE(Map)
00284
00285 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
00286
00288 typedef typename internal::traits<Map<LieAlgebra<A>, MapOptions, StrideType> >::Coefficients Coefficients;
00289
00291 Map(const A& a) : m_coeffs(a.data()) {};
00293 Map(Scalar* data) : m_coeffs(data) {};
00295 Map(const Map& m) : m_coeffs(m.get()) {};
00296
00298 Coefficients& get() { return m_coeffs; }
00300 const Coefficients& get() const { return m_coeffs; }
00301
00302 protected:
00304 Coefficients m_coeffs;
00305 };
00306
00307 template<class A, int MapOptions, typename StrideType>
00308 class Map<const LieAlgebra<A>, MapOptions, StrideType> : public LieAlgebraBase<A, Map<const LieAlgebra<A>, MapOptions, StrideType> > {
00309 protected:
00311 typedef LieAlgebraBase<A, Map<const LieAlgebra<A>, MapOptions, StrideType> > Base;
00312 public:
00313
00314 EIGEN_DENSE_PUBLIC_INTERFACE(Map)
00315
00316
00317 typedef typename internal::traits<Map<const LieAlgebra<A>, MapOptions, StrideType> >::Coefficients Coefficients;
00318
00320 Map(const A& a) : m_coeffs(a.data()) {};
00322 Map(const Scalar* data) : m_coeffs(data) {};
00324 Map(const Map& m) : m_coeffs(m.get()) {};
00325
00327 Coefficients& get() { return m_coeffs; }
00329 const Coefficients& get() const { return m_coeffs; }
00330
00331 protected:
00333 Coefficients m_coeffs;
00334 };
00335
00336
00337
00338
00339
00340
00341 namespace internal {
00342 template<class A, int MapOptions, typename StrideType>
00343 struct traits<Map<LieAlgebraDual<A>, MapOptions, StrideType> > : public traits<LieAlgebraDualBase<A, Map<LieAlgebraDual<A>, MapOptions, StrideType> > >
00344 {
00345 typedef Map<A, MapOptions, StrideType> Coefficients;
00346 };
00347
00348 template<class A, int MapOptions, typename StrideType>
00349 struct traits<Map<const LieAlgebraDual<A>, MapOptions, StrideType> > : public traits<LieAlgebraDualBase<A, Map<const LieAlgebraDual<A>, MapOptions, StrideType> > >
00350 {
00351 typedef Map<A, MapOptions, StrideType> Coefficients;
00352 };
00353
00354 }
00369 template<class A, int MapOptions, typename StrideType>
00370 class Map<LieAlgebraDual<A>, MapOptions, StrideType> : public LieAlgebraDualBase<A, Map<LieAlgebraDual<A>, MapOptions, StrideType> > {
00371 protected:
00373 typedef LieAlgebraDualBase<A, Map<LieAlgebraDual<A>, MapOptions, StrideType> > Base;
00374 public:
00375
00376 EIGEN_DENSE_PUBLIC_INTERFACE(Map)
00377
00378 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
00379
00381 typedef typename internal::traits<Map<LieAlgebraDual<A>, MapOptions, StrideType> >::Coefficients Coefficients;
00382
00384 Map(const A& a) : m_coeffs(a) {};
00386 Map(Scalar* data) : m_coeffs(data) {};
00388 Map(const Map& m) : m_coeffs(m.get()) {};
00389
00391 Coefficients& get() { return m_coeffs; }
00393 const Coefficients& get() const { return m_coeffs; }
00394
00395 protected:
00397 Coefficients m_coeffs;
00398 };
00399
00400 template<class A, int MapOptions, typename StrideType>
00401 class Map<const LieAlgebraDual<A>, MapOptions, StrideType> : public LieAlgebraDualBase<A, Map<const LieAlgebraDual<A>, MapOptions, StrideType> > {
00402 protected:
00404 typedef LieAlgebraDualBase<A, Map<const LieAlgebraDual<A>, MapOptions, StrideType> > Base;
00405 public:
00406
00407 EIGEN_DENSE_PUBLIC_INTERFACE(Map)
00408
00409
00410 typedef typename internal::traits<Map<const LieAlgebraDual<A>, MapOptions, StrideType> >::Coefficients Coefficients;
00411
00413 Map(const A& a) : m_coeffs(a) {};
00415 Map(const Scalar* data) : m_coeffs(data) {};
00417 Map(const Map& m) : m_coeffs(m.get()) {};
00418
00420 Coefficients& get() { return m_coeffs; }
00422 const Coefficients& get() const { return m_coeffs; }
00423
00424 protected:
00426 Coefficients m_coeffs;
00427 };
00428
00429 #endif
00430