From f8b96ad0909703c3f27efa7fabe9215f37e4f3cf Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Tue, 9 Oct 2012 17:48:38 +0000 Subject: [PATCH] Added print() to Reduction --- gtsam/inference/Permutation.cpp | 12 ++++++++++-- gtsam/inference/Permutation.h | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gtsam/inference/Permutation.cpp b/gtsam/inference/Permutation.cpp index f94b4e116..883041b86 100644 --- a/gtsam/inference/Permutation.cpp +++ b/gtsam/inference/Permutation.cpp @@ -200,6 +200,13 @@ namespace internal { return it->second; } + /* ************************************************************************* */ + void Reduction::print(const std::string& s) const { + cout << s << " reduction:" << endl; + BOOST_FOREACH(const value_type& p, *this) + cout << " " << p.first << " : " << p.second << endl; + } + /* ************************************************************************* */ Permutation createReducingPermutation(const std::set& indices) { Permutation p(indices.size()); @@ -210,6 +217,7 @@ namespace internal { } return p; } -} +} // \namespace internal -} +/* ************************************************************************* */ +} // \namespace gtsam diff --git a/gtsam/inference/Permutation.h b/gtsam/inference/Permutation.h index 45fd4b377..6014d704e 100644 --- a/gtsam/inference/Permutation.h +++ b/gtsam/inference/Permutation.h @@ -189,11 +189,15 @@ namespace internal { // An internal class used for storing and applying a permutation from a map class Reduction : public gtsam::FastMap { public: + typedef gtsam::FastMap Base; + static Reduction CreateAsInverse(const Permutation& p); void applyInverse(std::vector& js) const; Permutation inverse() const; Index& operator[](const Index& j); const Index& operator[](const Index& j) const; + + void print(const std::string& s="") const; }; // Reduce the variable indices so that those in the set are mapped to start at zero