diff --git a/gtsam/base/concepts.h b/gtsam/base/concepts.h index 6910518da..d3f2fe87c 100644 --- a/gtsam/base/concepts.h +++ b/gtsam/base/concepts.h @@ -95,8 +95,12 @@ template struct DefaultChart; namespace group { -template -G compose(const G&g, const G& h); +/** @name Free functions any Group needs to define */ +//@{ +template G compose(const G&g, const G& h); +template G between(const G&g, const G& h); +template G inverse(const G&g); +//@} namespace traits { @@ -126,39 +130,41 @@ public: typedef typename traits::structure_category::type structure_category_tag; typedef typename group::traits::identity::value_type identity_value_type; - typedef typename group::traits::flavor::type group_flavor_tag; + typedef typename group::traits::flavor::type flavor_tag; BOOST_CONCEPT_USAGE(Group) { using group::compose; + using group::between; + using group::inverse; BOOST_STATIC_ASSERT( boost::is_base_of::value); e = group::traits::identity::value; - pq = compose(p, q); -// G ip = inverse(p); -// G d = between(p, q); -// test = equal(p, q); -// test2 = operator_usage(p, q, group::traits::_flavor::type); + d = compose(g, h); + d = between(g, h); + ig = inverse(g); + test = operator_usage(g, h, flavor); +// test2 = equal(g, h); } bool check_invariants(const G& a, const G& b) { - group_flavor_tag group_flavor; return (equal(compose(a, inverse(a)), e)) && (equal(between(a, b), compose(inverse(a), b))) && (equal(compose(a, between(a, b)), b)) - && operator_usage(a, b, group_flavor); + && operator_usage(a, b, flavor); } private: - G e, p, q, pq, ip, d; + flavor_tag flavor; + G e, g, h, gh, ig, d; bool test, test2; bool operator_usage(const G& a, const G& b, group::traits::multiplicative_tag) { - return equal(compose(a, b), a * b); + return group::compose(a, b) == a * b; } bool operator_usage(const G& a, const G& b, group::traits::additive_tag) { - return equal(compose(a, b), a + b); + return group::compose(a, b) == a + b; } }; @@ -193,7 +199,7 @@ private: } private: - V p,q,r; + V g,q,r; }; */ diff --git a/gtsam/geometry/tests/testCyclic.cpp b/gtsam/geometry/tests/testCyclic.cpp index 7bc19a2b7..882d8fb1c 100644 --- a/gtsam/geometry/tests/testCyclic.cpp +++ b/gtsam/geometry/tests/testCyclic.cpp @@ -45,6 +45,12 @@ namespace group { template Cyclic compose(const Cyclic&g, const Cyclic& h); +template +Cyclic between(const Cyclic&g, const Cyclic& h); + +template +Cyclic inverse(const Cyclic&g); + namespace traits { /// Define the trait that specifies Cyclic's identity element template struct identity > {