gtsam
Loading...
Searching...
No Matches
AsVectorSpace.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
17
18#pragma once
19
20#include <gtsam/base/VectorSpace.h>
21
22namespace gtsam {
23
42template <class Class>
43class AsVectorSpace : public Class {
44 public:
48 inline constexpr static int dimension = traits<Class>::dimension;
49
51 AsVectorSpace() : Class(Class()) {}
52
54 explicit AsVectorSpace(const Class& value) : Class(value) {}
55
57 explicit AsVectorSpace(const TangentVector& tangent)
58 : Class(traits<Class>::Retract(Class(), tangent)) {}
59
61 static AsVectorSpace Identity() { return AsVectorSpace(); }
62
65 const TangentVector tangent =
66 traits<Class>::Local(Class(), static_cast<const Class&>(other));
67 return AsVectorSpace(
68 traits<Class>::Retract(static_cast<const Class&>(*this), tangent));
69 }
70
73 const TangentVector tangent =
74 traits<Class>::Local(Class(), static_cast<const Class&>(other));
75 return AsVectorSpace(
76 traits<Class>::Retract(static_cast<const Class&>(*this), -tangent));
77 }
78
81 const TangentVector tangent =
82 traits<Class>::Local(Class(), static_cast<const Class&>(*this));
83 return AsVectorSpace(traits<Class>::Retract(Class(), -tangent));
84 }
85
87 AsVectorSpace operator+(const TangentVector& tangent) const {
88 return AsVectorSpace(
89 traits<Class>::Retract(static_cast<const Class&>(*this), tangent));
90 }
91
93 AsVectorSpace operator-(const TangentVector& tangent) const {
94 return AsVectorSpace(
95 traits<Class>::Retract(static_cast<const Class&>(*this), -tangent));
96 }
97
100 return traits<Class>::Local(Class(), static_cast<const Class&>(*this));
101 }
102};
103
105template <class Class>
106struct traits<AsVectorSpace<Class>>
107 : internal::VectorSpaceTraits<AsVectorSpace<Class>>,
108 Testable<AsVectorSpace<Class>> {};
109
111template <class Class>
112struct traits<const AsVectorSpace<Class>> : traits<AsVectorSpace<Class>> {};
113
114} // namespace gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
A helper that implements the traits interface for classes that define vector spaces To use this for y...
Definition VectorSpace.h:199
Opt-in adapter that equips a manifold class with additive vector-space operations.
Definition AsVectorSpace.h:43
AsVectorSpace(const Class &value)
Wrap an existing manifold value.
Definition AsVectorSpace.h:54
AsVectorSpace()
Construct the selected additive identity.
Definition AsVectorSpace.h:51
static AsVectorSpace Identity()
Return the selected additive identity.
Definition AsVectorSpace.h:61
TangentVector vector() const
Return coordinates relative to the selected additive identity.
Definition AsVectorSpace.h:99
AsVectorSpace operator-() const
Negate the wrapped value's coordinates about the identity.
Definition AsVectorSpace.h:80
AsVectorSpace(const TangentVector &tangent)
Retract a tangent vector from the selected identity.
Definition AsVectorSpace.h:57
static constexpr int dimension
Compile-time dimension inherited from the wrapped manifold.
Definition AsVectorSpace.h:48
AsVectorSpace operator+(const AsVectorSpace &other) const
Add another wrapped value using its coordinates about the identity.
Definition AsVectorSpace.h:64
typename traits< Class >::TangentVector TangentVector
Tangent coordinates supplied by the wrapped manifold traits.
Definition AsVectorSpace.h:46
AsVectorSpace operator-(const TangentVector &tangent) const
Retract a negated tangent increment from the current wrapped value.
Definition AsVectorSpace.h:93
AsVectorSpace operator+(const TangentVector &tangent) const
Retract a tangent increment from the current wrapped value.
Definition AsVectorSpace.h:87
AsVectorSpace operator-(const AsVectorSpace &other) const
Subtract another wrapped value using its coordinates about the identity.
Definition AsVectorSpace.h:72