diff --git a/cpp/FactorGraph-inl.h b/cpp/FactorGraph-inl.h index 3ee00b433..1fca15477 100644 --- a/cpp/FactorGraph-inl.h +++ b/cpp/FactorGraph-inl.h @@ -29,10 +29,6 @@ /*template boost::shared_ptr removeAndCombineFactors(FactorGraph&, const std::string&);*/ \ template FactorGraph combine(const FactorGraph&, const FactorGraph&); - -// trick from some reading group -#define FOREACH_PAIR( KEY, VAL, COL) BOOST_FOREACH (boost::tie(KEY,VAL),COL) - using namespace std; namespace gtsam { @@ -340,7 +336,7 @@ PredecessorMap FactorGraph::findMinimumSpanningTree() const { template template void FactorGraph::split(const PredecessorMap& tree, FactorGraph& Ab1, FactorGraph& Ab2) const{ - BOOST_FOREACH(sharedFactor factor, factors_){ + BOOST_FOREACH(const sharedFactor& factor, factors_){ if (factor->keys().size() > 2) throw(invalid_argument("split: only support factors with at most two keys")); diff --git a/cpp/NonlinearFactorGraph-inl.h b/cpp/NonlinearFactorGraph-inl.h index 01ef0a82c..b34580ac0 100644 --- a/cpp/NonlinearFactorGraph-inl.h +++ b/cpp/NonlinearFactorGraph-inl.h @@ -25,7 +25,7 @@ namespace gtsam { template Vector NonlinearFactorGraph::unwhitenedError(const Config& c) const { list errors; - BOOST_FOREACH(typename NonlinearFactorGraph::sharedFactor factor, this->factors_) + BOOST_FOREACH(const sharedFactor& factor, this->factors_) errors.push_back(factor->unwhitenedError(c)); return concatVectors(errors); } @@ -35,7 +35,7 @@ namespace gtsam { double NonlinearFactorGraph::error(const Config& c) const { double total_error = 0.; // iterate over all the factors_ to accumulate the log probabilities - BOOST_FOREACH(typename NonlinearFactorGraph::sharedFactor factor, this->factors_) + BOOST_FOREACH(const sharedFactor& factor, this->factors_) total_error += factor->error(c); return total_error; } @@ -49,8 +49,7 @@ namespace gtsam { boost::shared_ptr linearFG(new GaussianFactorGraph); // linearize all factors - typedef typename NonlinearFactorGraph::sharedFactor Factor; - BOOST_FOREACH(const Factor& factor, this->factors_) { + BOOST_FOREACH(const sharedFactor& factor, this->factors_) { boost::shared_ptr lf = factor->linearize(config); linearFG->push_back(lf); } diff --git a/cpp/NonlinearFactorGraph.h b/cpp/NonlinearFactorGraph.h index ddcecd459..497d31052 100644 --- a/cpp/NonlinearFactorGraph.h +++ b/cpp/NonlinearFactorGraph.h @@ -30,6 +30,8 @@ namespace gtsam { public: + typedef typename boost::shared_ptr > sharedFactor; + /** unnormalized error */ double error(const Config& c) const;