Fixed many warnings with Clang, reformatted using BORG template.

release/4.3a0
dellaert 2014-11-25 09:57:31 +01:00
parent 97d6088467
commit ce033f5594
2 changed files with 115 additions and 98 deletions

View File

@ -17,16 +17,15 @@
#pragma once
#include <boost/foreach.hpp>
#include <map>
#include <vector>
namespace gtsam {
/* ************************************************************************* */
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> >::iterator iAdjMapIt;
std::set<Key> keySet;
@ -74,7 +73,8 @@ void MetisIndex::augment(const FactorGraph<FACTOR>& factors)
for (iAdjMapIt = iAdjMap.begin(); iAdjMapIt != iAdjMap.end(); ++iAdjMapIt) {
std::vector<idx_t> temp;
// 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_
adj_.insert(adj_.end(), temp.begin(), temp.end());
//adj_.push_back(temp);
@ -82,4 +82,4 @@ void MetisIndex::augment(const FactorGraph<FACTOR>& factors)
}
}
}
} // \ gtsam

View File

@ -6,7 +6,6 @@
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/**
@ -17,16 +16,25 @@
#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/FactorGraph.h>
#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__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wredeclared-class-member"
#endif
#include <boost/bimap.hpp>
#ifdef __clang__
# pragma clang diagnostic pop
#endif
#include <vector>
namespace gtsam {
/**
@ -36,8 +44,7 @@ namespace gtsam {
* that involve each variable.
* \nosubgrouping
*/
class GTSAM_EXPORT MetisIndex
{
class GTSAM_EXPORT MetisIndex {
public:
typedef boost::shared_ptr<MetisIndex> shared_ptr;
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> iadj_; // Integer keys for passing into metis. One to one mapping with adj_;
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_;
public:
@ -55,13 +61,18 @@ public:
/// @{
/** Default constructor, creates empty MetisIndex */
MetisIndex() : nFactors_(0), nKeys_(0) {}
MetisIndex() :
nKeys_(0) {
}
template<class FG>
MetisIndex(const FG& factorGraph) : nFactors_(0), nKeys_(0) {
augment(factorGraph); }
MetisIndex(const FG& factorGraph) :
nKeys_(0) {
augment(factorGraph);
}
~MetisIndex(){}
~MetisIndex() {
}
/// @}
/// @name Advanced Interface
/// @{
@ -73,9 +84,15 @@ public:
template<class FACTOR>
void augment(const FactorGraph<FACTOR>& factors);
std::vector<idx_t> xadj() const { return xadj_; }
std::vector<idx_t> adj() const { return adj_; }
size_t nValues() const { return nKeys_; }
std::vector<idx_t> xadj() const {
return xadj_;
}
std::vector<idx_t> adj() const {
return adj_;
}
size_t nValues() const {
return nKeys_;
}
Key intToKey(idx_t value) const {
assert(value >= 0);
return intKeyBMap_.right.find(value)->second;
@ -84,6 +101,6 @@ public:
/// @}
};
}
} // \ namesace gtsam
#include <gtsam/inference/MetisIndex-inl.h>