diff --git a/gtsam/base/Group.h b/gtsam/base/Group.h index 8a1d69848..a5ae6ba1c 100644 --- a/gtsam/base/Group.h +++ b/gtsam/base/Group.h @@ -128,7 +128,7 @@ compose_pow(const G& g, size_t n) { /// Template to construct the direct product of two arbitrary groups /// Assumes nothing except group structure from G and H -template +template class DirectProduct: public std::pair { BOOST_CONCEPT_ASSERT((IsGroup)); BOOST_CONCEPT_ASSERT((IsGroup)); @@ -143,23 +143,22 @@ public: // Construct from two subgroup elements DirectProduct(const G& g, const H& h):std::pair(g,h) {} - DirectProduct operator*(const DirectProduct& other) const { - return DirectProduct(traits::Compose(g(),other.g()), traits::Compose(h(),other.h())); + Derived operator*(const Derived& other) const { + return Derived(traits::Compose(g(),other.g()), traits::Compose(h(),other.h())); } - DirectProduct inverse() const { - return DirectProduct(g().inverse(), h().inverse()); + Derived inverse() const { + return Derived(g().inverse(), h().inverse()); } }; // Define any direct product group to be a model of the multiplicative Group concept -template -struct traits > : internal::MultiplicativeGroupTraits< - DirectProduct > { -}; +template +struct traits > : + internal::MultiplicativeGroupTraits > {}; /// Template to construct the direct sum of two additive groups /// Assumes existence of three additive operators for both groups -template +template class DirectSum: public std::pair { BOOST_CONCEPT_ASSERT((IsGroup)); // TODO(frank): check additive BOOST_CONCEPT_ASSERT((IsGroup)); // TODO(frank): check additive @@ -174,20 +173,21 @@ public: // Construct from two subgroup elements DirectSum(const G& g, const H& h):std::pair(g,h) {} - DirectSum operator+(const DirectSum& other) const { + Derived operator+(const Derived& other) const { return DirectSum(g()+other.g(), h()+other.h()); } - DirectSum operator-(const DirectSum& other) const { - return DirectSum(g()-other.g(), h()-other.h()); + Derived operator-(const Derived& other) const { + return Derived(g()-other.g(), h()-other.h()); } - DirectSum operator-() const { - return DirectSum(- g(), - h()); + Derived operator-() const { + return Derived(- g(), - h()); } }; // Define direct sums to be a model of the Additive Group concept -template -struct traits > : internal::AdditiveGroupTraits > {}; +template +struct traits > : + internal::AdditiveGroupTraits > {}; } // namespace gtsam