Fixed many warnings with Clang, reformatted using BORG template.
parent
97d6088467
commit
ce033f5594
|
@ -1,32 +1,31 @@
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
|
|
||||||
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
|
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
|
||||||
* Atlanta, Georgia 30332-0415
|
* Atlanta, Georgia 30332-0415
|
||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
||||||
|
|
||||||
* See LICENSE for the license information
|
* See LICENSE for the license information
|
||||||
|
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file MetisIndex-inl.h
|
* @file MetisIndex-inl.h
|
||||||
* @author Andrew Melim
|
* @author Andrew Melim
|
||||||
* @date Oct. 10, 2014
|
* @date Oct. 10, 2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template<class FACTOR>
|
template<class FACTOR>
|
||||||
void MetisIndex::augment(const FactorGraph<FACTOR>& factors)
|
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> > 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<idx_t, FastSet<idx_t> >::iterator iAdjMapIt;
|
||||||
std::set<Key> keySet;
|
std::set<Key> keySet;
|
||||||
|
@ -41,11 +40,11 @@ void MetisIndex::augment(const FactorGraph<FACTOR>& factors)
|
||||||
|
|
||||||
// First: Record a copy of each key inside the factorgraph and create a
|
// First: Record a copy of each key inside the factorgraph and create a
|
||||||
// key to integer mapping. This is referenced during the adjaceny step
|
// key to integer mapping. This is referenced during the adjaceny step
|
||||||
for (size_t i = 0; i < factors.size(); i++){
|
for (size_t i = 0; i < factors.size(); i++) {
|
||||||
if (factors[i]) {
|
if (factors[i]) {
|
||||||
BOOST_FOREACH(const Key& key, *factors[i]){
|
BOOST_FOREACH(const Key& key, *factors[i]) {
|
||||||
keySet.insert(keySet.end(), key); // Keep a track of all unique keys
|
keySet.insert(keySet.end(), key); // Keep a track of all unique keys
|
||||||
if (intKeyBMap_.left.find(key) == intKeyBMap_.left.end()){
|
if (intKeyBMap_.left.find(key) == intKeyBMap_.left.end()) {
|
||||||
intKeyBMap_.insert(bm_type::value_type(key, keyCounter));
|
intKeyBMap_.insert(bm_type::value_type(key, keyCounter));
|
||||||
keyCounter++;
|
keyCounter++;
|
||||||
}
|
}
|
||||||
|
@ -54,11 +53,11 @@ void MetisIndex::augment(const FactorGraph<FACTOR>& factors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an adjacency mapping that stores the set of all adjacent keys for every key
|
// Create an adjacency mapping that stores the set of all adjacent keys for every key
|
||||||
for (size_t i = 0; i < factors.size(); i++){
|
for (size_t i = 0; i < factors.size(); i++) {
|
||||||
if (factors[i]){
|
if (factors[i]) {
|
||||||
BOOST_FOREACH(const Key& k1, *factors[i])
|
BOOST_FOREACH(const Key& k1, *factors[i])
|
||||||
BOOST_FOREACH(const Key& k2, *factors[i])
|
BOOST_FOREACH(const Key& k2, *factors[i])
|
||||||
if (k1 != k2){
|
if (k1 != k2) {
|
||||||
// Store both in Key and idx_t format
|
// Store both in Key and idx_t format
|
||||||
int i = intKeyBMap_.left.at(k1);
|
int i = intKeyBMap_.left.at(k1);
|
||||||
int j = intKeyBMap_.left.at(k2);
|
int j = intKeyBMap_.left.at(k2);
|
||||||
|
@ -70,16 +69,17 @@ void MetisIndex::augment(const FactorGraph<FACTOR>& factors)
|
||||||
// Number of keys referenced in this factor graph
|
// Number of keys referenced in this factor graph
|
||||||
nKeys_ = keySet.size();
|
nKeys_ = keySet.size();
|
||||||
|
|
||||||
xadj_.push_back(0);// Always set the first index to zero
|
xadj_.push_back(0); // Always set the first index to zero
|
||||||
for (iAdjMapIt = iAdjMap.begin(); iAdjMapIt != iAdjMap.end(); ++iAdjMapIt) {
|
for (iAdjMapIt = iAdjMap.begin(); iAdjMapIt != iAdjMap.end(); ++iAdjMapIt) {
|
||||||
std::vector<idx_t> temp;
|
std::vector<idx_t> temp;
|
||||||
// Copy from the FastSet into a temporary vector
|
// Copy from the FastSet into a temporary vector
|
||||||
std::copy(iAdjMapIt->second.begin(), iAdjMapIt->second.end(), std::back_inserter(temp));
|
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_
|
// Insert each index's set in order by appending them to the end of adj_
|
||||||
adj_.insert(adj_.end(), temp.begin(), temp.end());
|
adj_.insert(adj_.end(), temp.begin(), temp.end());
|
||||||
//adj_.push_back(temp);
|
//adj_.push_back(temp);
|
||||||
xadj_.push_back((idx_t)adj_.size());
|
xadj_.push_back((idx_t) adj_.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // \ gtsam
|
||||||
|
|
|
@ -1,32 +1,40 @@
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
|
|
||||||
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
|
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
|
||||||
* Atlanta, Georgia 30332-0415
|
* Atlanta, Georgia 30332-0415
|
||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
||||||
|
|
||||||
* See LICENSE for the license information
|
* See LICENSE for the license information
|
||||||
|
* -------------------------------------------------------------------------- */
|
||||||
* -------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file MetisIndex.h
|
* @file MetisIndex.h
|
||||||
* @author Andrew Melim
|
* @author Andrew Melim
|
||||||
* @date Oct. 10, 2014
|
* @date Oct. 10, 2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
|
|
||||||
#include <gtsam/base/FastList.h>
|
|
||||||
#include <gtsam/base/types.h>
|
|
||||||
#include <gtsam/base/timing.h>
|
|
||||||
#include <gtsam/inference/Key.h>
|
#include <gtsam/inference/Key.h>
|
||||||
#include <gtsam/inference/FactorGraph.h>
|
#include <gtsam/inference/FactorGraph.h>
|
||||||
|
#include <gtsam/base/FastVector.h>
|
||||||
|
#include <gtsam/base/types.h>
|
||||||
|
#include <gtsam/base/timing.h>
|
||||||
#include <gtsam/3rdparty/metis/metis.h>
|
#include <gtsam/3rdparty/metis/metis.h>
|
||||||
|
|
||||||
|
// Boost bimap generates many ugly warnings in CLANG
|
||||||
|
#ifdef __clang__
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# pragma clang diagnostic ignored "-Wredeclared-class-member"
|
||||||
|
#endif
|
||||||
#include <boost/bimap.hpp>
|
#include <boost/bimap.hpp>
|
||||||
|
#ifdef __clang__
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
/**
|
/**
|
||||||
|
@ -36,8 +44,7 @@ namespace gtsam {
|
||||||
* that involve each variable.
|
* that involve each variable.
|
||||||
* \nosubgrouping
|
* \nosubgrouping
|
||||||
*/
|
*/
|
||||||
class GTSAM_EXPORT MetisIndex
|
class GTSAM_EXPORT MetisIndex {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<MetisIndex> shared_ptr;
|
typedef boost::shared_ptr<MetisIndex> shared_ptr;
|
||||||
typedef boost::bimap<Key, idx_t> bm_type;
|
typedef boost::bimap<Key, idx_t> bm_type;
|
||||||
|
@ -47,7 +54,6 @@ private:
|
||||||
FastVector<idx_t> adj_; // Stores ajacency lists of all nodes, appended into a single vector
|
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_;
|
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
|
boost::bimap<Key, idx_t> intKeyBMap_; // Stores Key <-> integer value relationship
|
||||||
size_t nFactors_; // Number of factors in the original factor graph
|
|
||||||
size_t nKeys_;
|
size_t nKeys_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -55,13 +61,18 @@ public:
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
/** Default constructor, creates empty MetisIndex */
|
/** Default constructor, creates empty MetisIndex */
|
||||||
MetisIndex() : nFactors_(0), nKeys_(0) {}
|
MetisIndex() :
|
||||||
|
nKeys_(0) {
|
||||||
|
}
|
||||||
|
|
||||||
template<class FG>
|
template<class FG>
|
||||||
MetisIndex(const FG& factorGraph) : nFactors_(0), nKeys_(0) {
|
MetisIndex(const FG& factorGraph) :
|
||||||
augment(factorGraph); }
|
nKeys_(0) {
|
||||||
|
augment(factorGraph);
|
||||||
|
}
|
||||||
|
|
||||||
~MetisIndex(){}
|
~MetisIndex() {
|
||||||
|
}
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Advanced Interface
|
/// @name Advanced Interface
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -73,9 +84,15 @@ public:
|
||||||
template<class FACTOR>
|
template<class FACTOR>
|
||||||
void augment(const FactorGraph<FACTOR>& factors);
|
void augment(const FactorGraph<FACTOR>& factors);
|
||||||
|
|
||||||
std::vector<idx_t> xadj() const { return xadj_; }
|
std::vector<idx_t> xadj() const {
|
||||||
std::vector<idx_t> adj() const { return adj_; }
|
return xadj_;
|
||||||
size_t nValues() const { return nKeys_; }
|
}
|
||||||
|
std::vector<idx_t> adj() const {
|
||||||
|
return adj_;
|
||||||
|
}
|
||||||
|
size_t nValues() const {
|
||||||
|
return nKeys_;
|
||||||
|
}
|
||||||
Key intToKey(idx_t value) const {
|
Key intToKey(idx_t value) const {
|
||||||
assert(value >= 0);
|
assert(value >= 0);
|
||||||
return intKeyBMap_.right.find(value)->second;
|
return intKeyBMap_.right.find(value)->second;
|
||||||
|
@ -84,6 +101,6 @@ public:
|
||||||
/// @}
|
/// @}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // \ namesace gtsam
|
||||||
|
|
||||||
#include <gtsam/inference/MetisIndex-inl.h>
|
#include <gtsam/inference/MetisIndex-inl.h>
|
||||||
|
|
Loading…
Reference in New Issue