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