Converted VariableIndex to use a deque instead of a vector. The deque performs incremental memory allocation, resulting in a significant speed improvement in iSAM2.
parent
fd4f11d21e
commit
483e2ec959
|
|
@ -68,7 +68,7 @@ void VariableIndex::outputMetisFormat(ostream& os) const {
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void VariableIndex::permuteInPlace(const Permutation& permutation) {
|
void VariableIndex::permuteInPlace(const Permutation& permutation) {
|
||||||
// Create new index and move references to data into it in permuted order
|
// Create new index and move references to data into it in permuted order
|
||||||
vector<VariableIndex::Factors> newIndex(this->size());
|
deque<VariableIndex::Factors> newIndex(this->size());
|
||||||
for(Index i = 0; i < newIndex.size(); ++i)
|
for(Index i = 0; i < newIndex.size(); ++i)
|
||||||
newIndex[i].swap(this->index_[permutation[i]]);
|
newIndex[i].swap(this->index_[permutation[i]]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <deque>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
|
@ -33,7 +34,7 @@ namespace gtsam {
|
||||||
* factor graph. The factor graph stores a collection of factors, each of
|
* factor graph. The factor graph stores a collection of factors, each of
|
||||||
* which involves a set of variables. In contrast, the VariableIndex is built
|
* which involves a set of variables. In contrast, the VariableIndex is built
|
||||||
* from a factor graph prior to elimination, and stores the list of factors
|
* from a factor graph prior to elimination, and stores the list of factors
|
||||||
* that involve each variable. This information is stored as a vector of
|
* that involve each variable. This information is stored as a deque of
|
||||||
* lists of factor indices.
|
* lists of factor indices.
|
||||||
* \nosubgrouping
|
* \nosubgrouping
|
||||||
*/
|
*/
|
||||||
|
|
@ -46,7 +47,7 @@ public:
|
||||||
typedef Factors::const_iterator Factor_const_iterator;
|
typedef Factors::const_iterator Factor_const_iterator;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<Factors> index_;
|
std::deque<Factors> index_;
|
||||||
size_t nFactors_; // Number of factors in the original factor graph.
|
size_t nFactors_; // Number of factors in the original factor graph.
|
||||||
size_t nEntries_; // Sum of involved variable counts of each factor.
|
size_t nEntries_; // Sum of involved variable counts of each factor.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue