use BOOST_FOREACH

release/4.3a0
Frank Dellaert 2009-12-18 02:48:21 +00:00
parent a1918056a5
commit a3deb992c4
1 changed files with 7 additions and 11 deletions

View File

@ -8,6 +8,7 @@
#pragma once
#include <boost/foreach.hpp>
#include "GaussianFactorGraph.h"
#include "NonlinearFactorGraph.h"
@ -18,11 +19,8 @@ namespace gtsam {
double NonlinearFactorGraph<Config>::error(const Config& c) const {
double total_error = 0.;
// iterate over all the factors_ to accumulate the log probabilities
typedef typename FactorGraph<NonlinearFactor<Config> >::const_iterator
const_iterator;
for (const_iterator factor = this->factors_.begin(); factor
!= this->factors_.end(); factor++)
total_error += (*factor)->error(c);
BOOST_FOREACH(typename NonlinearFactorGraph<Config>::sharedFactor factor, this->factors_)
total_error += factor->error(c);
return total_error;
}
@ -34,12 +32,9 @@ namespace gtsam {
// create an empty linear FG
boost::shared_ptr<GaussianFactorGraph> linearFG(new GaussianFactorGraph);
typedef typename FactorGraph<NonlinearFactor<Config> >::const_iterator
const_iterator;
// linearize all factors
for (const_iterator factor = this->factors_.begin(); factor
< this->factors_.end(); factor++) {
boost::shared_ptr<GaussianFactor> lf = (*factor)->linearize(config);
BOOST_FOREACH(typename NonlinearFactorGraph<Config>::sharedFactor factor, this->factors_) {
boost::shared_ptr<GaussianFactor> lf = factor->linearize(config);
linearFG->push_back(lf);
}
return linearFG;
@ -50,4 +45,5 @@ namespace gtsam {
const Config& config) const {
return *linearize_(config);
}
}
} // namespace gtsam