Remove header from MetisIndex, replace idx_t with int32_t
parent
c90bc5c34a
commit
e9f4b1d65a
|
@ -26,8 +26,8 @@ namespace gtsam {
|
|||
/* ************************************************************************* */
|
||||
template<class FACTOR>
|
||||
void MetisIndex::augment(const FactorGraph<FACTOR>& factors) {
|
||||
std::map<idx_t, FastSet<idx_t> > iAdjMap; // Stores a set of keys that are adjacent to key x, with adjMap.first
|
||||
std::map<idx_t, FastSet<idx_t> >::iterator iAdjMapIt;
|
||||
std::map<int32_t, FastSet<int32_t> > iAdjMap; // Stores a set of keys that are adjacent to key x, with adjMap.first
|
||||
std::map<int32_t, FastSet<int32_t> >::iterator iAdjMapIt;
|
||||
std::set<Key> keySet;
|
||||
|
||||
/* ********** Convert to CSR format ********** */
|
||||
|
@ -36,7 +36,7 @@ void MetisIndex::augment(const FactorGraph<FACTOR>& factors) {
|
|||
// starting at index xadj[i] and ending at(but not including)
|
||||
// index xadj[i + 1](i.e., adjncy[xadj[i]] through
|
||||
// and including adjncy[xadj[i + 1] - 1]).
|
||||
idx_t keyCounter = 0;
|
||||
int32_t keyCounter = 0;
|
||||
|
||||
// First: Record a copy of each key inside the factorgraph and create a
|
||||
// key to integer mapping. This is referenced during the adjaceny step
|
||||
|
@ -58,7 +58,7 @@ void MetisIndex::augment(const FactorGraph<FACTOR>& factors) {
|
|||
BOOST_FOREACH(const Key& k1, *factors[i])
|
||||
BOOST_FOREACH(const Key& k2, *factors[i])
|
||||
if (k1 != k2) {
|
||||
// Store both in Key and idx_t format
|
||||
// Store both in Key and int32_t format
|
||||
int i = intKeyBMap_.left.at(k1);
|
||||
int j = intKeyBMap_.left.at(k2);
|
||||
iAdjMap[i].insert(iAdjMap[i].end(), j);
|
||||
|
@ -71,14 +71,14 @@ void MetisIndex::augment(const FactorGraph<FACTOR>& factors) {
|
|||
|
||||
xadj_.push_back(0); // Always set the first index to zero
|
||||
for (iAdjMapIt = iAdjMap.begin(); iAdjMapIt != iAdjMap.end(); ++iAdjMapIt) {
|
||||
std::vector<idx_t> temp;
|
||||
std::vector<int32_t> temp;
|
||||
// Copy from the FastSet into a temporary vector
|
||||
std::copy(iAdjMapIt->second.begin(), iAdjMapIt->second.end(),
|
||||
std::back_inserter(temp));
|
||||
// Insert each index's set in order by appending them to the end of adj_
|
||||
adj_.insert(adj_.end(), temp.begin(), temp.end());
|
||||
//adj_.push_back(temp);
|
||||
xadj_.push_back((idx_t) adj_.size());
|
||||
xadj_.push_back((int32_t) adj_.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <gtsam/base/FastVector.h>
|
||||
#include <gtsam/base/types.h>
|
||||
#include <gtsam/base/timing.h>
|
||||
#include <gtsam/3rdparty/metis/metis.h>
|
||||
|
||||
// Boost bimap generates many ugly warnings in CLANG
|
||||
#ifdef __clang__
|
||||
|
@ -47,13 +46,13 @@ namespace gtsam {
|
|||
class GTSAM_EXPORT MetisIndex {
|
||||
public:
|
||||
typedef boost::shared_ptr<MetisIndex> shared_ptr;
|
||||
typedef boost::bimap<Key, idx_t> bm_type;
|
||||
typedef boost::bimap<Key, int32_t> bm_type;
|
||||
|
||||
private:
|
||||
FastVector<idx_t> xadj_; // Index of node's adjacency list in adj
|
||||
FastVector<idx_t> adj_; // Stores ajacency lists of all nodes, appended into a single vector
|
||||
FastVector<idx_t> iadj_; // Integer keys for passing into metis. One to one mapping with adj_;
|
||||
boost::bimap<Key, idx_t> intKeyBMap_; // Stores Key <-> integer value relationship
|
||||
FastVector<int32_t> xadj_; // Index of node's adjacency list in adj
|
||||
FastVector<int32_t> adj_; // Stores ajacency lists of all nodes, appended into a single vector
|
||||
FastVector<int32_t> iadj_; // Integer keys for passing into metis. One to one mapping with adj_;
|
||||
boost::bimap<Key, int32_t> intKeyBMap_; // Stores Key <-> integer value relationship
|
||||
size_t nKeys_;
|
||||
|
||||
public:
|
||||
|
@ -84,16 +83,16 @@ public:
|
|||
template<class FACTOR>
|
||||
void augment(const FactorGraph<FACTOR>& factors);
|
||||
|
||||
std::vector<idx_t> xadj() const {
|
||||
std::vector<int32_t> xadj() const {
|
||||
return xadj_;
|
||||
}
|
||||
std::vector<idx_t> adj() const {
|
||||
std::vector<int32_t> adj() const {
|
||||
return adj_;
|
||||
}
|
||||
size_t nValues() const {
|
||||
return nKeys_;
|
||||
}
|
||||
Key intToKey(idx_t value) const {
|
||||
Key intToKey(int32_t value) const {
|
||||
assert(value >= 0);
|
||||
return intKeyBMap_.right.find(value)->second;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue