From a464769ce1bdbc3aef20ee7bcb126f16bad36140 Mon Sep 17 00:00:00 2001 From: Yao Chen Date: Fri, 20 May 2016 21:29:02 -0400 Subject: [PATCH] Replaced BOOSE_FOREACH with for in tests folder. Tested the changed code locally: successful. --- tests/testGaussianBayesTreeB.cpp | 3 +-- tests/testGaussianFactorGraphB.cpp | 3 +-- tests/testGaussianISAM.cpp | 5 ++--- tests/testGaussianISAM2.cpp | 11 +++++------ tests/testGeneralSFMFactorB.cpp | 3 +-- tests/testSubgraphPreconditioner.cpp | 2 +- tests/testSubgraphSolver.cpp | 3 +-- 7 files changed, 12 insertions(+), 18 deletions(-) diff --git a/tests/testGaussianBayesTreeB.cpp b/tests/testGaussianBayesTreeB.cpp index e3c17fa3f..8b2aa3ae7 100644 --- a/tests/testGaussianBayesTreeB.cpp +++ b/tests/testGaussianBayesTreeB.cpp @@ -26,7 +26,6 @@ #include -#include #include // for operator += using namespace boost::assign; @@ -220,7 +219,7 @@ TEST( GaussianBayesTree, balanced_smoother_shortcuts ) // Permutation toFront(Permutation::PullToFront(C3->keys(), varIndex.size())); // Permutation toFrontInverse(*toFront.inverse()); // varIndex.permute(toFront); -// BOOST_FOREACH(const GaussianFactor::shared_ptr& factor, marginal) { +// for(const GaussianFactor::shared_ptr& factor: marginal) { // factor->permuteWithInverse(toFrontInverse); } // GaussianBayesNet actual = *inference::EliminateUntil(marginal, C3->keys().size(), varIndex); // actual.permuteWithInverse(toFront); diff --git a/tests/testGaussianFactorGraphB.cpp b/tests/testGaussianFactorGraphB.cpp index 10de57435..eec62ff9c 100644 --- a/tests/testGaussianFactorGraphB.cpp +++ b/tests/testGaussianFactorGraphB.cpp @@ -26,7 +26,6 @@ #include -#include #include #include // for operator += #include // for operator += @@ -585,7 +584,7 @@ TEST( GaussianFactorGraph, conditional_sigma_failure) { GaussianBayesTree actBT = *lfg.eliminateMultifrontal(); // Check that all sigmas in an unconstrained bayes tree are set to one - BOOST_FOREACH(const GaussianBayesTree::sharedClique& clique, actBT.nodes() | br::map_values) { + for(const GaussianBayesTree::sharedClique& clique: actBT.nodes() | br::map_values) { GaussianConditional::shared_ptr conditional = clique->conditional(); //size_t dim = conditional->rows(); //EXPECT(assert_equal(gtsam::Vector::Ones(dim), conditional->get_model()->sigmas(), tol)); diff --git a/tests/testGaussianISAM.cpp b/tests/testGaussianISAM.cpp index 7f53406c8..07323e0fc 100644 --- a/tests/testGaussianISAM.cpp +++ b/tests/testGaussianISAM.cpp @@ -22,7 +22,6 @@ #include #include -#include #include // for operator += using namespace boost::assign; #include @@ -46,7 +45,7 @@ TEST( ISAM, iSAM_smoother ) // run iSAM for every factor GaussianISAM actual; - BOOST_FOREACH(boost::shared_ptr factor, smoother) { + for(boost::shared_ptr factor: smoother) { GaussianFactorGraph factorGraph; factorGraph.push_back(factor); actual.update(factorGraph); @@ -56,7 +55,7 @@ TEST( ISAM, iSAM_smoother ) GaussianBayesTree expected = *smoother.eliminateMultifrontal(ordering); // Verify sigmas in the bayes tree - BOOST_FOREACH(const GaussianBayesTree::sharedClique& clique, expected.nodes() | br::map_values) { + for(const GaussianBayesTree::sharedClique& clique: expected.nodes() | br::map_values) { GaussianConditional::shared_ptr conditional = clique->conditional(); EXPECT(!conditional->get_model()); } diff --git a/tests/testGaussianISAM2.cpp b/tests/testGaussianISAM2.cpp index d358caa35..f56b458be 100644 --- a/tests/testGaussianISAM2.cpp +++ b/tests/testGaussianISAM2.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include using namespace boost::assign; @@ -212,7 +211,7 @@ struct ConsistencyVisitor if(find(node->parent()->children.begin(), node->parent()->children.end(), node) == node->parent()->children.end()) consistent = false; } - BOOST_FOREACH(Key j, node->conditional()->frontals()) + for(Key j: node->conditional()->frontals()) { if(isam.nodes().at(j).get() != node.get()) consistent = false; @@ -251,7 +250,7 @@ bool isam_check(const NonlinearFactorGraph& fullgraph, const Values& fullinit, c // Check gradient at each node bool nodeGradientsOk = true; typedef ISAM2::sharedClique sharedClique; - BOOST_FOREACH(const sharedClique& clique, isam.nodes() | br::map_values) { + for(const sharedClique& clique: isam.nodes() | br::map_values) { // Compute expected gradient GaussianFactorGraph jfg; jfg += clique->conditional(); @@ -483,7 +482,7 @@ TEST(ISAM2, swapFactors) // Check gradient at each node typedef ISAM2::sharedClique sharedClique; - BOOST_FOREACH(const sharedClique& clique, isam.nodes() | br::map_values) { + for(const sharedClique& clique: isam.nodes() | br::map_values) { // Compute expected gradient GaussianFactorGraph jfg; jfg += clique->conditional(); @@ -608,7 +607,7 @@ TEST(ISAM2, constrained_ordering) // Check gradient at each node typedef ISAM2::sharedClique sharedClique; - BOOST_FOREACH(const sharedClique& clique, isam.nodes() | br::map_values) { + for(const sharedClique& clique: isam.nodes() | br::map_values) { // Compute expected gradient GaussianFactorGraph jfg; jfg += clique->conditional(); @@ -650,7 +649,7 @@ namespace { bool checkMarginalizeLeaves(ISAM2& isam, const FastList& leafKeys) { Matrix expectedAugmentedHessian, expected3AugmentedHessian; vector toKeep; - BOOST_FOREACH(Key j, isam.getDelta() | br::map_keys) + for(Key j: isam.getDelta() | br::map_keys) if(find(leafKeys.begin(), leafKeys.end(), j) == leafKeys.end()) toKeep.push_back(j); diff --git a/tests/testGeneralSFMFactorB.cpp b/tests/testGeneralSFMFactorB.cpp index aea18c90d..410617cbf 100644 --- a/tests/testGeneralSFMFactorB.cpp +++ b/tests/testGeneralSFMFactorB.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -51,7 +50,7 @@ TEST(PinholeCamera, BAL) { NonlinearFactorGraph graph; for (size_t j = 0; j < db.number_tracks(); j++) { - BOOST_FOREACH (const SfM_Measurement& m, db.tracks[j].measurements) + for (const SfM_Measurement& m: db.tracks[j].measurements) graph.push_back(sfmFactor(m.second, unit2, m.first, P(j))); } diff --git a/tests/testSubgraphPreconditioner.cpp b/tests/testSubgraphPreconditioner.cpp index 6a49f66d3..a43137126 100644 --- a/tests/testSubgraphPreconditioner.cpp +++ b/tests/testSubgraphPreconditioner.cpp @@ -57,7 +57,7 @@ TEST( SubgraphPreconditioner, planarOrdering ) { /** unnormalized error */ static double error(const GaussianFactorGraph& fg, const VectorValues& x) { double total_error = 0.; - BOOST_FOREACH(const GaussianFactor::shared_ptr& factor, fg) + for(const GaussianFactor::shared_ptr& factor: fg) total_error += factor->error(x); return total_error; } diff --git a/tests/testSubgraphSolver.cpp b/tests/testSubgraphSolver.cpp index f5d0384f2..aeeed1b9f 100644 --- a/tests/testSubgraphSolver.cpp +++ b/tests/testSubgraphSolver.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include using namespace boost::assign; @@ -41,7 +40,7 @@ using namespace example; /** unnormalized error */ static double error(const GaussianFactorGraph& fg, const VectorValues& x) { double total_error = 0.; - BOOST_FOREACH(const GaussianFactor::shared_ptr& factor, fg) + for(const GaussianFactor::shared_ptr& factor: fg) total_error += factor->error(x); return total_error; }