25#include <boost/concept_check.hpp>
26#include <boost/concept/requires.hpp>
27#include <boost/type_traits/is_base_of.hpp>
28#include <boost/static_assert.hpp>
40template <
typename T>
struct traits;
53 BOOST_STATIC_ASSERT_MSG(
54 (boost::is_base_of<group_tag, structure_category_tag>::value),
55 "This type's structure_category trait does not assert it as a group (or derived)");
60 operator_usage(flavor);
83check_group_invariants(
const G& a,
const G& b,
double tol = 1e-9) {
95struct MultiplicativeGroupTraits {
96 typedef group_tag structure_category;
97 typedef multiplicative_group_tag group_flavor;
98 static Class Identity() {
return Class::identity(); }
99 static Class Compose(
const Class &g,
const Class & h) {
return g * h;}
100 static Class Between(
const Class &g,
const Class & h) {
return g.inverse() * h;}
101 static Class Inverse(
const Class &g) {
return g.inverse();}
106struct MultiplicativeGroup : MultiplicativeGroupTraits<Class>, Testable<Class> {};
111struct AdditiveGroupTraits {
112 typedef group_tag structure_category;
113 typedef additive_group_tag group_flavor;
114 static Class Identity() {
return Class::identity(); }
115 static Class Compose(
const Class &g,
const Class & h) {
return g + h;}
116 static Class Between(
const Class &g,
const Class & h) {
return h - g;}
117 static Class Inverse(
const Class &g) {
return -g;}
122struct AdditiveGroup : AdditiveGroupTraits<Class>, Testable<Class> {};
129compose_pow(
const G& g,
size_t n) {
130 if (n == 0)
return traits<G>::Identity();
131 else if (n == 1)
return g;
132 else return traits<G>::Compose(compose_pow(g, n - 1), g);
137template<
typename G,
typename H>
153 return DirectProduct(traits<G>::Compose(this->first, other.first),
154 traits<H>::Compose(this->second, other.second));
157 return DirectProduct(this->first.inverse(), this->second.inverse());
162template<
typename G,
typename H>
164 internal::MultiplicativeGroupTraits<DirectProduct<G, H> > {};
168template<
typename G,
typename H>
173 const G& g()
const {
return this->first; }
174 const H& h()
const {
return this->second;}
181 DirectSum(
const G& g,
const H& h):std::pair<G,H>(g,h) {}
187 return DirectSum(g()+other.g(), h()+other.h());
190 return DirectSum(g()-other.g(), h()-other.h());
198template<
typename G,
typename H>
200 internal::AdditiveGroupTraits<DirectSum<G, H> > {};
212#define GTSAM_CONCEPT_GROUP_INST(T) template class gtsam::IsGroup<T>;
213#define GTSAM_CONCEPT_GROUP_TYPE(T) typedef gtsam::IsGroup<T> _gtsam_IsGroup_##T;
Concept check for values that can be used in unit tests.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
BOOST_CONCEPT_REQUIRES(((IsGroup< G >)),(bool)) check_group_invariants(const G &a
Check invariants.
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
tag to assert a type is a group
Definition: Group.h:34
Group operator syntax flavors.
Definition: Group.h:37
Group Concept.
Definition: Group.h:46
DirectProduct()
Default constructor yields identity.
Definition: Group.h:144
Template to construct the direct sum of two additive groups Assumes existence of three additive opera...
Definition: Group.h:169
DirectSum()
Default constructor yields identity.
Definition: Group.h:178