/* ---------------------------------------------------------------------------- * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) * See LICENSE for the license information * -------------------------------------------------------------------------- */ /** * @file Permutation.cpp * @brief * @author Richard Roberts * @created Oct 9, 2010 */ #include #include #include using namespace std; namespace gtsam { /* ************************************************************************* */ Permutation Permutation::Identity(Index nVars) { Permutation ret(nVars); for(Index i=0; i& toFront, size_t size) { Permutation ret(size); // Mask of which variables have been pulled, used to reorder vector pulled(size, false); // Put the pulled variables at the front of the permutation and set up the // pulled flags. for(Index j=0; j& toBack, size_t size) { Permutation ret(size); // Mask of which variables have been pushed, used to reorder vector pushed(size, false); // Put the pushed variables at the back of the permutation and set up the // pushed flags; Index nextVar = size - toBack.size(); for(Index j=0; jsize())); for(Index i=0; isize(); ++i) { assert((*this)[i] < this->size()); (*result)[(*this)[i]] = i; } return result; } /* ************************************************************************* */ void Permutation::print(const std::string& str) const { std::cout << str; BOOST_FOREACH(Index s, rangeIndices_) { std::cout << s << " "; } std::cout << std::endl; } }