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