/** * @file Permutation.cpp * @brief * @author Richard Roberts * @created Oct 9, 2010 */ #include #include #include using namespace std; namespace gtsam { /* ************************************************************************* */ Permutation Permutation::Identity(varid_t nVars) { Permutation ret(nVars); for(varid_t 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(varid_t 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; varid_t nextVar = size - toBack.size(); for(varid_t j=0; jsize())); for(varid_t 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(varid_t s, rangeIndices_) { std::cout << s << " "; } std::cout << std::endl; } }