Replaced BOOSE_FOREACH with for in examples folder. Tested the changed code locally: successful.
parent
27f0bfa411
commit
a9b4bfd261
|
@ -56,7 +56,7 @@ int main(const int argc, const char *argv[]) {
|
|||
std::cout << "Rewriting input to file: " << inputFileRewritten << std::endl;
|
||||
// Additional: rewrite input with simplified keys 0,1,...
|
||||
Values simpleInitial;
|
||||
BOOST_FOREACH(const Values::ConstKeyValuePair& key_value, *initial) {
|
||||
for(const Values::ConstKeyValuePair& key_value: *initial) {
|
||||
Key key;
|
||||
if(add)
|
||||
key = key_value.key + firstKey;
|
||||
|
@ -66,7 +66,7 @@ int main(const int argc, const char *argv[]) {
|
|||
simpleInitial.insert(key, initial->at(key_value.key));
|
||||
}
|
||||
NonlinearFactorGraph simpleGraph;
|
||||
BOOST_FOREACH(const boost::shared_ptr<NonlinearFactor>& factor, *graph) {
|
||||
for(const boost::shared_ptr<NonlinearFactor>& factor: *graph) {
|
||||
boost::shared_ptr<BetweenFactor<Pose3> > pose3Between =
|
||||
boost::dynamic_pointer_cast<BetweenFactor<Pose3> >(factor);
|
||||
if (pose3Between){
|
||||
|
|
|
@ -45,7 +45,7 @@ int main(const int argc, const char *argv[]) {
|
|||
noiseModel::Diagonal::shared_ptr priorModel = //
|
||||
noiseModel::Diagonal::Variances((Vector(6) << 1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4).finished());
|
||||
Key firstKey = 0;
|
||||
BOOST_FOREACH(const Values::ConstKeyValuePair& key_value, *initial) {
|
||||
for(const Values::ConstKeyValuePair& key_value: *initial) {
|
||||
std::cout << "Adding prior to g2o file " << std::endl;
|
||||
firstKey = key_value.key;
|
||||
graphWithPrior.add(PriorFactor<Pose3>(firstKey, Pose3(), priorModel));
|
||||
|
|
|
@ -45,7 +45,7 @@ int main(const int argc, const char *argv[]) {
|
|||
noiseModel::Diagonal::shared_ptr priorModel = //
|
||||
noiseModel::Diagonal::Variances((Vector(6) << 1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4).finished());
|
||||
Key firstKey = 0;
|
||||
BOOST_FOREACH(const Values::ConstKeyValuePair& key_value, *initial) {
|
||||
for(const Values::ConstKeyValuePair& key_value: *initial) {
|
||||
std::cout << "Adding prior to g2o file " << std::endl;
|
||||
firstKey = key_value.key;
|
||||
graphWithPrior.add(PriorFactor<Pose3>(firstKey, Pose3(), priorModel));
|
||||
|
|
|
@ -45,7 +45,7 @@ int main(const int argc, const char *argv[]) {
|
|||
noiseModel::Diagonal::shared_ptr priorModel = //
|
||||
noiseModel::Diagonal::Variances((Vector(6) << 1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4).finished());
|
||||
Key firstKey = 0;
|
||||
BOOST_FOREACH(const Values::ConstKeyValuePair& key_value, *initial) {
|
||||
for(const Values::ConstKeyValuePair& key_value: *initial) {
|
||||
std::cout << "Adding prior to g2o file " << std::endl;
|
||||
firstKey = key_value.key;
|
||||
graphWithPrior.add(PriorFactor<Pose3>(firstKey, Pose3(), priorModel));
|
||||
|
|
|
@ -151,7 +151,7 @@ int main (int argc, char** argv) {
|
|||
|
||||
// Loop over odometry
|
||||
gttic_(iSAM);
|
||||
BOOST_FOREACH(const TimedOdometry& timedOdometry, odometry) {
|
||||
for(const TimedOdometry& timedOdometry: odometry) {
|
||||
//--------------------------------- odometry loop -----------------------------------------
|
||||
double t;
|
||||
Pose2 odometry;
|
||||
|
@ -196,7 +196,7 @@ int main (int argc, char** argv) {
|
|||
}
|
||||
i += 1;
|
||||
//--------------------------------- odometry loop -----------------------------------------
|
||||
} // BOOST_FOREACH
|
||||
} // end for
|
||||
gttoc_(iSAM);
|
||||
|
||||
// Print timings
|
||||
|
|
|
@ -80,7 +80,7 @@ double chi2_red(const gtsam::NonlinearFactorGraph& graph, const gtsam::Values& c
|
|||
// the factor graph already includes a factor for the prior/equality constraint.
|
||||
// double dof = graph.size() - config.size();
|
||||
int graph_dim = 0;
|
||||
BOOST_FOREACH(const boost::shared_ptr<gtsam::NonlinearFactor>& nlf, graph) {
|
||||
for(const boost::shared_ptr<gtsam::NonlinearFactor>& nlf: graph) {
|
||||
graph_dim += (int)nlf->dim();
|
||||
}
|
||||
double dof = double(graph_dim) - double(config.dim()); // kaess: changed to dim
|
||||
|
@ -442,7 +442,7 @@ void runIncremental()
|
|||
// break;
|
||||
// }
|
||||
// tictoc_print_();
|
||||
// BOOST_FOREACH(Key key, values.keys()) {
|
||||
// for(Key key: values.keys()) {
|
||||
// gttic_(marginalInformation);
|
||||
// Matrix info = marginals.marginalInformation(key);
|
||||
// gttoc_(marginalInformation);
|
||||
|
@ -535,7 +535,7 @@ void runCompare()
|
|||
vector<Key> commonKeys;
|
||||
br::set_intersection(soln1.keys(), soln2.keys(), std::back_inserter(commonKeys));
|
||||
double maxDiff = 0.0;
|
||||
BOOST_FOREACH(Key j, commonKeys)
|
||||
for(Key j: commonKeys)
|
||||
maxDiff = std::max(maxDiff, soln1.at(j).localCoordinates_(soln2.at(j)).norm());
|
||||
cout << " Maximum solution difference (norm of logmap): " << maxDiff << endl;
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ void runPerturb()
|
|||
|
||||
// Perturb values
|
||||
VectorValues noise;
|
||||
BOOST_FOREACH(const Values::KeyValuePair& key_val, initial)
|
||||
for(const Values::KeyValuePair& key_val: initial)
|
||||
{
|
||||
Vector noisev(key_val.value.dim());
|
||||
for(Vector::Index i = 0; i < noisev.size(); ++i)
|
||||
|
|
|
@ -76,7 +76,7 @@ map<int, double> testWithoutMemoryAllocation()
|
|||
|
||||
const vector<size_t> grainSizes = list_of(1)(10)(100)(1000);
|
||||
map<int, double> timingResults;
|
||||
BOOST_FOREACH(size_t grainSize, grainSizes)
|
||||
for(size_t grainSize: grainSizes)
|
||||
{
|
||||
tbb::tick_count t0 = tbb::tick_count::now();
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, numberOfProblems), WorkerWithoutAllocation(results));
|
||||
|
@ -129,7 +129,7 @@ map<int, double> testWithMemoryAllocation()
|
|||
|
||||
const vector<size_t> grainSizes = list_of(1)(10)(100)(1000);
|
||||
map<int, double> timingResults;
|
||||
BOOST_FOREACH(size_t grainSize, grainSizes)
|
||||
for(size_t grainSize: grainSizes)
|
||||
{
|
||||
tbb::tick_count t0 = tbb::tick_count::now();
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, numberOfProblems), WorkerWithAllocation(results));
|
||||
|
@ -150,7 +150,7 @@ int main(int argc, char* argv[])
|
|||
const vector<int> numThreads = list_of(1)(4)(8);
|
||||
Results results;
|
||||
|
||||
BOOST_FOREACH(size_t n, numThreads)
|
||||
for(size_t n: numThreads)
|
||||
{
|
||||
cout << "With " << n << " threads:" << endl;
|
||||
tbb::task_scheduler_init init((int)n);
|
||||
|
@ -160,19 +160,19 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
cout << "Summary of results:" << endl;
|
||||
BOOST_FOREACH(const Results::value_type& threads_result, results)
|
||||
for(const Results::value_type& threads_result: results)
|
||||
{
|
||||
const int threads = threads_result.first;
|
||||
const ResultWithThreads& result = threads_result.second;
|
||||
if(threads != 1)
|
||||
{
|
||||
BOOST_FOREACH(const ResultWithThreads::value_type& grainsize_time, result.grainSizesWithoutAllocation)
|
||||
for(const ResultWithThreads::value_type& grainsize_time: result.grainSizesWithoutAllocation)
|
||||
{
|
||||
const int grainsize = grainsize_time.first;
|
||||
const double speedup = results[1].grainSizesWithoutAllocation[grainsize] / grainsize_time.second;
|
||||
cout << threads << " threads, without allocation, grain size = " << grainsize << ", speedup = " << speedup << endl;
|
||||
}
|
||||
BOOST_FOREACH(const ResultWithThreads::value_type& grainsize_time, result.grainSizesWithAllocation)
|
||||
for(const ResultWithThreads::value_type& grainsize_time: result.grainSizesWithAllocation)
|
||||
{
|
||||
const int grainsize = grainsize_time.first;
|
||||
const double speedup = results[1].grainSizesWithAllocation[grainsize] / grainsize_time.second;
|
||||
|
|
Loading…
Reference in New Issue