From 773d4975e6046ee4e710cd218ede3837587f776a Mon Sep 17 00:00:00 2001 From: kartik arcot Date: Thu, 19 Jan 2023 15:58:17 -0800 Subject: [PATCH] remove all adaptors --- examples/RangeISAMExample_plaza2.cpp | 6 +-- examples/SolverComparer.cpp | 2 - gtsam/discrete/DecisionTreeFactor.h | 1 - gtsam/discrete/DiscreteBayesNet.cpp | 5 ++- gtsam/discrete/DiscreteLookupDAG.cpp | 7 ++- gtsam/inference/BayesNet-inst.h | 4 +- gtsam/linear/GaussianBayesNet.cpp | 14 +++--- gtsam/linear/HessianFactor.cpp | 18 ++++---- gtsam/linear/JacobianFactor.cpp | 12 ++--- gtsam/linear/SubgraphPreconditioner.cpp | 4 +- gtsam/linear/VectorValues.cpp | 5 --- gtsam/linear/tests/testJacobianFactor.cpp | 7 ++- gtsam/linear/tests/testVectorValues.cpp | 3 -- gtsam/nonlinear/ISAM2-impl.h | 7 --- gtsam/nonlinear/ISAM2.cpp | 6 ++- .../symbolic/tests/testSymbolicBayesTree.cpp | 44 ++++++++++++------- .../discrete/tests/testLoopyBelief.cpp | 19 ++++---- .../examples/SmartRangeExample_plaza1.cpp | 6 +-- .../examples/SmartRangeExample_plaza2.cpp | 6 +-- gtsam_unstable/linear/LPInitSolver.cpp | 4 +- timing/timeIncremental.cpp | 10 +++-- 21 files changed, 96 insertions(+), 94 deletions(-) diff --git a/examples/RangeISAMExample_plaza2.cpp b/examples/RangeISAMExample_plaza2.cpp index 73c69862d..39cc6c4ef 100644 --- a/examples/RangeISAMExample_plaza2.cpp +++ b/examples/RangeISAMExample_plaza2.cpp @@ -178,10 +178,10 @@ int main(int argc, char** argv) { initial.insert(i, predictedPose); // Check if there are range factors to be added - while (k < K && t >= boost::get<0>(triples[k])) { - size_t j = boost::get<1>(triples[k]); + while (k < K && t >= std::get<0>(triples[k])) { + size_t j = std::get<1>(triples[k]); Symbol landmark_key('L', j); - double range = boost::get<2>(triples[k]); + double range = std::get<2>(triples[k]); newFactors.emplace_shared>( i, landmark_key, range, rangeNoise); if (initializedLandmarks.count(landmark_key) == 0) { diff --git a/examples/SolverComparer.cpp b/examples/SolverComparer.cpp index 4cbaaf617..34b30c10a 100644 --- a/examples/SolverComparer.cpp +++ b/examples/SolverComparer.cpp @@ -49,8 +49,6 @@ #include #include #include -#include -#include #include #include diff --git a/gtsam/discrete/DecisionTreeFactor.h b/gtsam/discrete/DecisionTreeFactor.h index 74899b729..e59552007 100644 --- a/gtsam/discrete/DecisionTreeFactor.h +++ b/gtsam/discrete/DecisionTreeFactor.h @@ -268,5 +268,4 @@ namespace gtsam { // traits template <> struct traits : public Testable {}; - } // namespace gtsam diff --git a/gtsam/discrete/DiscreteBayesNet.cpp b/gtsam/discrete/DiscreteBayesNet.cpp index 451f5f07b..66c0a72e9 100644 --- a/gtsam/discrete/DiscreteBayesNet.cpp +++ b/gtsam/discrete/DiscreteBayesNet.cpp @@ -58,8 +58,9 @@ DiscreteValues DiscreteBayesNet::sample() const { DiscreteValues DiscreteBayesNet::sample(DiscreteValues result) const { // sample each node in turn in topological sort order (parents first) - for (auto conditional : boost::adaptors::reverse(*this)) - conditional->sampleInPlace(&result); + for (auto it = std::make_reverse_iterator(end()); it != std::make_reverse_iterator(begin()); ++it) { + (*it)->sampleInPlace(&result); + } return result; } diff --git a/gtsam/discrete/DiscreteLookupDAG.cpp b/gtsam/discrete/DiscreteLookupDAG.cpp index bdc77031c..ab62055ed 100644 --- a/gtsam/discrete/DiscreteLookupDAG.cpp +++ b/gtsam/discrete/DiscreteLookupDAG.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -118,8 +119,10 @@ DiscreteLookupDAG DiscreteLookupDAG::FromBayesNet( DiscreteValues DiscreteLookupDAG::argmax(DiscreteValues result) const { // Argmax each node in turn in topological sort order (parents first). - for (auto lookupTable : boost::adaptors::reverse(*this)) - lookupTable->argmaxInPlace(&result); + for (auto it = std::make_reverse_iterator(end()); it != std::make_reverse_iterator(begin()); ++it) { + // dereference to get the sharedFactor to the lookup table + (*it)->argmaxInPlace(&result); + } return result; } /* ************************************************************************** */ diff --git a/gtsam/inference/BayesNet-inst.h b/gtsam/inference/BayesNet-inst.h index f06008c88..6d436d079 100644 --- a/gtsam/inference/BayesNet-inst.h +++ b/gtsam/inference/BayesNet-inst.h @@ -56,7 +56,9 @@ void BayesNet::dot(std::ostream& os, os << "\n"; // Reverse order as typically Bayes nets stored in reverse topological sort. - for (auto conditional : boost::adaptors::reverse(*this)) { + for (auto it = std::make_reverse_iterator(this->end()); + it != std::make_reverse_iterator(this->begin()); ++it) { + const auto& conditional = *it; auto frontals = conditional->frontals(); const Key me = frontals.front(); auto parents = conditional->parents(); diff --git a/gtsam/linear/GaussianBayesNet.cpp b/gtsam/linear/GaussianBayesNet.cpp index 2e62d2d42..b04878ac5 100644 --- a/gtsam/linear/GaussianBayesNet.cpp +++ b/gtsam/linear/GaussianBayesNet.cpp @@ -20,8 +20,8 @@ #include #include -#include #include +#include using namespace std; using namespace gtsam; @@ -50,11 +50,11 @@ namespace gtsam { VectorValues solution = given; // (R*x)./sigmas = y by solving x=inv(R)*(y.*sigmas) // solve each node in reverse topological sort order (parents first) - for (auto cg : boost::adaptors::reverse(*this)) { + for (auto it = std::make_reverse_iterator(end()); it != std::make_reverse_iterator(begin()); ++it) { // i^th part of R*x=y, x=inv(R)*y // (Rii*xi + R_i*x(i+1:))./si = yi => // xi = inv(Rii)*(yi.*si - R_i*x(i+1:)) - solution.insert(cg->solve(solution)); + solution.insert((*it)->solve(solution)); } return solution; } @@ -69,8 +69,8 @@ namespace gtsam { std::mt19937_64* rng) const { VectorValues result(given); // sample each node in reverse topological sort order (parents first) - for (auto cg : boost::adaptors::reverse(*this)) { - const VectorValues sampled = cg->sample(result, rng); + for (auto it = std::make_reverse_iterator(end()); it != std::make_reverse_iterator(begin()); ++it) { + const VectorValues sampled = (*it)->sample(result, rng); result.insert(sampled); } return result; @@ -131,8 +131,8 @@ namespace gtsam { VectorValues result; // TODO this looks pretty sketchy. result is passed as the parents argument // as it's filled up by solving the gaussian conditionals. - for (auto cg: boost::adaptors::reverse(*this)) { - result.insert(cg->solveOtherRHS(result, rhs)); + for (auto it = std::make_reverse_iterator(end()); it != std::make_reverse_iterator(begin()); ++it) { + result.insert((*it)->solveOtherRHS(result, rhs)); } return result; } diff --git a/gtsam/linear/HessianFactor.cpp b/gtsam/linear/HessianFactor.cpp index cf815ee3a..50a9cac9b 100644 --- a/gtsam/linear/HessianFactor.cpp +++ b/gtsam/linear/HessianFactor.cpp @@ -31,18 +31,12 @@ #include #include -#include -#include -#include #include #include +#include "gtsam/base/Vector.h" using namespace std; -namespace br { -using namespace boost::range; -using namespace boost::adaptors; -} namespace gtsam { @@ -144,12 +138,20 @@ namespace { DenseIndex _getSizeHF(const Vector& m) { return m.size(); } + +std::vector _getSizeHFVec(const std::vector& m) { + std::vector dims; + for (const Vector& v : m) { + dims.push_back(v.size()); + } + return dims; +} } /* ************************************************************************* */ HessianFactor::HessianFactor(const KeyVector& js, const std::vector& Gs, const std::vector& gs, double f) : - GaussianFactor(js), info_(gs | br::transformed(&_getSizeHF), true) { + GaussianFactor(js), info_(_getSizeHFVec(gs), true) { // Get the number of variables size_t variable_count = js.size(); diff --git a/gtsam/linear/JacobianFactor.cpp b/gtsam/linear/JacobianFactor.cpp index 6779a033f..9f6b8da16 100644 --- a/gtsam/linear/JacobianFactor.cpp +++ b/gtsam/linear/JacobianFactor.cpp @@ -32,10 +32,6 @@ #include #include -#include -#include -#include -#include #include #include @@ -227,10 +223,10 @@ void JacobianFactor::JacobianFactorHelper(const GaussianFactorGraph& graph, gttic(allocate); Ab_ = VerticalBlockMatrix(varDims, m, true); // Allocate augmented matrix Base::keys_.resize(orderedSlots.size()); - boost::range::copy( - // Get variable keys - orderedSlots | boost::adaptors::indirected | boost::adaptors::map_keys, - Base::keys_.begin()); + // Copy keys in order + std::transform(orderedSlots.begin(), orderedSlots.end(), + Base::keys_.begin(), + [](const VariableSlots::const_iterator& it) {return it->first;}); gttoc(allocate); // Loop over slots in combined factor and copy blocks from source factors diff --git a/gtsam/linear/SubgraphPreconditioner.cpp b/gtsam/linear/SubgraphPreconditioner.cpp index b0a84bc2e..ece8d13d4 100644 --- a/gtsam/linear/SubgraphPreconditioner.cpp +++ b/gtsam/linear/SubgraphPreconditioner.cpp @@ -25,7 +25,6 @@ #include #include -#include #include @@ -205,7 +204,8 @@ void SubgraphPreconditioner::solve(const Vector &y, Vector &x) const { assert(x.size() == y.size()); /* back substitute */ - for (const auto &cg : boost::adaptors::reverse(Rc1_)) { + for (auto it = std::make_reverse_iterator(Rc1_.end()); it != std::make_reverse_iterator(Rc1_.begin()); ++it) { + auto& cg = *it; /* collect a subvector of x that consists of the parents of cg (S) */ const KeyVector parentKeys(cg->beginParents(), cg->endParents()); const KeyVector frontalKeys(cg->beginFrontals(), cg->endFrontals()); diff --git a/gtsam/linear/VectorValues.cpp b/gtsam/linear/VectorValues.cpp index 2e9dd24d0..e95e2e38d 100644 --- a/gtsam/linear/VectorValues.cpp +++ b/gtsam/linear/VectorValues.cpp @@ -20,16 +20,11 @@ #include #include -#include -#include using namespace std; namespace gtsam { - using boost::adaptors::transformed; - using boost::accumulate; - /* ************************************************************************ */ VectorValues::VectorValues(const VectorValues& first, const VectorValues& second) { diff --git a/gtsam/linear/tests/testJacobianFactor.cpp b/gtsam/linear/tests/testJacobianFactor.cpp index df8aef2bd..52d85bd41 100644 --- a/gtsam/linear/tests/testJacobianFactor.cpp +++ b/gtsam/linear/tests/testJacobianFactor.cpp @@ -26,7 +26,6 @@ #include #include -#include using namespace std; using namespace gtsam; @@ -131,7 +130,11 @@ TEST(JacobianFactor, constructors_and_accessors) blockMatrix(1) = terms[1].second; blockMatrix(2) = terms[2].second; blockMatrix(3) = b; - JacobianFactor actual(terms | boost::adaptors::map_keys, blockMatrix, noise); + // get a vector of keys from the terms + vector keys; + for (const auto& term : terms) + keys.push_back(term.first); + JacobianFactor actual(keys, blockMatrix, noise); EXPECT(assert_equal(expected, actual)); LONGS_EQUAL((long)terms[2].first, (long)actual.keys().back()); EXPECT(assert_equal(terms[2].second, actual.getA(actual.end() - 1))); diff --git a/gtsam/linear/tests/testVectorValues.cpp b/gtsam/linear/tests/testVectorValues.cpp index 49fc56d19..a4e101658 100644 --- a/gtsam/linear/tests/testVectorValues.cpp +++ b/gtsam/linear/tests/testVectorValues.cpp @@ -21,12 +21,9 @@ #include -#include - #include using namespace std; -using boost::adaptors::map_keys; using namespace gtsam; /* ************************************************************************* */ diff --git a/gtsam/nonlinear/ISAM2-impl.h b/gtsam/nonlinear/ISAM2-impl.h index 8c0af2c2d..ad53b7972 100644 --- a/gtsam/nonlinear/ISAM2-impl.h +++ b/gtsam/nonlinear/ISAM2-impl.h @@ -28,13 +28,6 @@ #include #include -#include -#include -namespace br { -using namespace boost::range; -using namespace boost::adaptors; -} // namespace br - #include #include #include diff --git a/gtsam/nonlinear/ISAM2.cpp b/gtsam/nonlinear/ISAM2.cpp index dafe938c6..7f2dfa6e8 100644 --- a/gtsam/nonlinear/ISAM2.cpp +++ b/gtsam/nonlinear/ISAM2.cpp @@ -176,9 +176,11 @@ void ISAM2::recalculateBatch(const ISAM2UpdateParams& updateParams, gttic(recalculateBatch); gttic(add_keys); - br::copy(variableIndex_ | br::map_keys, - std::inserter(*affectedKeysSet, affectedKeysSet->end())); + // copy the keys from the variableIndex_ to the affectedKeysSet + for (const auto& [key, _] : variableIndex_) { + affectedKeysSet->insert(key); + } // Removed unused keys: VariableIndex affectedFactorsVarIndex = variableIndex_; diff --git a/gtsam/symbolic/tests/testSymbolicBayesTree.cpp b/gtsam/symbolic/tests/testSymbolicBayesTree.cpp index d14523719..6051fa95f 100644 --- a/gtsam/symbolic/tests/testSymbolicBayesTree.cpp +++ b/gtsam/symbolic/tests/testSymbolicBayesTree.cpp @@ -22,11 +22,10 @@ #include #include -#include -using boost::adaptors::indirected; - #include #include +#include +#include using namespace std; using namespace gtsam; @@ -34,6 +33,24 @@ using namespace gtsam::symbol_shorthand; static bool debug = false; +// Given a vector of shared pointers infer the type of the pointed-to objects +template +using PointedToType = std::decay_t().begin())>; + +// Given a vector of shared pointers infer the type of the pointed-to objects +template +using ValuesVector = std::vector>; + +// Return a vector of dereferenced values +template +ValuesVector deref(const T& v) { + ValuesVector result; + for (auto& t : v) + result.push_back(*t); + return result; +} + + /* ************************************************************************* */ TEST(SymbolicBayesTree, clear) { SymbolicBayesTree bayesTree = asiaBayesTree; @@ -111,8 +128,7 @@ TEST(BayesTree, removePath) { bayesTree.removePath(bayesTree[_C_], &bn, &orphans); SymbolicFactorGraph factors(bn); CHECK(assert_equal(expected, factors)); - CHECK(assert_container_equal(expectedOrphans | indirected, - orphans | indirected)); + CHECK(assert_container_equal(deref(expectedOrphans), deref(orphans))); bayesTree = bayesTreeOrig; @@ -127,8 +143,7 @@ TEST(BayesTree, removePath) { bayesTree.removePath(bayesTree[_E_], &bn2, &orphans2); SymbolicFactorGraph factors2(bn2); CHECK(assert_equal(expected2, factors2)); - CHECK(assert_container_equal(expectedOrphans2 | indirected, - orphans2 | indirected)); + CHECK(assert_container_equal(deref(expectedOrphans2), deref(orphans2))); } /* ************************************************************************* */ @@ -147,8 +162,7 @@ TEST(BayesTree, removePath2) { CHECK(assert_equal(expected, factors)); SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_S_], bayesTree[_T_], bayesTree[_X_]}; - CHECK(assert_container_equal(expectedOrphans | indirected, - orphans | indirected)); + CHECK(assert_container_equal(deref(expectedOrphans), deref(orphans))); } /* ************************************************************************* */ @@ -167,8 +181,7 @@ TEST(BayesTree, removePath3) { expected.emplace_shared(_T_, _E_, _L_); CHECK(assert_equal(expected, factors)); SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_S_], bayesTree[_X_]}; - CHECK(assert_container_equal(expectedOrphans | indirected, - orphans | indirected)); + CHECK(assert_container_equal(deref(expectedOrphans), deref(orphans))); } void getAllCliques(const SymbolicBayesTree::sharedClique& subtree, @@ -249,8 +262,7 @@ TEST(BayesTree, removeTop) { CHECK(assert_equal(expected, bn)); SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_T_], bayesTree[_X_]}; - CHECK(assert_container_equal(expectedOrphans | indirected, - orphans | indirected)); + CHECK(assert_container_equal(deref(expectedOrphans), deref(orphans))); // Try removeTop again with a factor that should not change a thing // std::shared_ptr newFactor2(new IndexFactor(_B_)); @@ -261,8 +273,7 @@ TEST(BayesTree, removeTop) { SymbolicFactorGraph expected2; CHECK(assert_equal(expected2, factors2)); SymbolicBayesTree::Cliques expectedOrphans2; - CHECK(assert_container_equal(expectedOrphans2 | indirected, - orphans2 | indirected)); + CHECK(assert_container_equal(deref(expectedOrphans2), deref(orphans2))); } /* ************************************************************************* */ @@ -286,8 +297,7 @@ TEST(BayesTree, removeTop2) { CHECK(assert_equal(expected, bn)); SymbolicBayesTree::Cliques expectedOrphans{bayesTree[_S_], bayesTree[_X_]}; - CHECK(assert_container_equal(expectedOrphans | indirected, - orphans | indirected)); + CHECK(assert_container_equal(deref(expectedOrphans), deref(orphans))); } /* ************************************************************************* */ diff --git a/gtsam_unstable/discrete/tests/testLoopyBelief.cpp b/gtsam_unstable/discrete/tests/testLoopyBelief.cpp index a34efe665..440593e7d 100644 --- a/gtsam_unstable/discrete/tests/testLoopyBelief.cpp +++ b/gtsam_unstable/discrete/tests/testLoopyBelief.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -47,7 +46,7 @@ class LoopyBelief { void print(const std::string& s = "") const { cout << s << ":" << endl; star->print("Star graph: "); - for (Key key : correctedBeliefIndices | boost::adaptors::map_keys) { + for (const auto& [key, _] : correctedBeliefIndices) { cout << "Belief factor index for " << key << ": " << correctedBeliefIndices.at(key) << endl; } @@ -71,7 +70,7 @@ class LoopyBelief { /// print void print(const std::string& s = "") const { cout << s << ":" << endl; - for (Key key : starGraphs_ | boost::adaptors::map_keys) { + for (const auto& [key, _] : starGraphs_) { starGraphs_.at(key).print((boost::format("Node %d:") % key).str()); } } @@ -85,7 +84,7 @@ class LoopyBelief { DiscreteFactorGraph::shared_ptr beliefs(new DiscreteFactorGraph()); std::map > allMessages; // Eliminate each star graph - for (Key key : starGraphs_ | boost::adaptors::map_keys) { + for (const auto& [key, _] : starGraphs_) { // cout << "***** Node " << key << "*****" << endl; // initialize belief to the unary factor from the original graph DecisionTreeFactor::shared_ptr beliefAtKey; @@ -94,8 +93,7 @@ class LoopyBelief { std::map messages; // eliminate each neighbor in this star graph one by one - for (Key neighbor : starGraphs_.at(key).correctedBeliefIndices | - boost::adaptors::map_keys) { + for (const auto& [neighbor, _] : starGraphs_.at(key).correctedBeliefIndices) { DiscreteFactorGraph subGraph; for (size_t factor : starGraphs_.at(key).varIndex_[neighbor]) { subGraph.push_back(starGraphs_.at(key).star->at(factor)); @@ -143,11 +141,10 @@ class LoopyBelief { // Update corrected beliefs VariableIndex beliefFactors(*beliefs); - for (Key key : starGraphs_ | boost::adaptors::map_keys) { + for (const auto& [key, _] : starGraphs_) { std::map messages = allMessages[key]; - for (Key neighbor : starGraphs_.at(key).correctedBeliefIndices | - boost::adaptors::map_keys) { - DecisionTreeFactor correctedBelief = + for (const auto& [neighbor, _] : starGraphs_.at(key).correctedBeliefIndices) { + DecisionTreeFactor correctedBelief = (*std::dynamic_pointer_cast( beliefs->at(beliefFactors[key].front()))) / (*std::dynamic_pointer_cast( @@ -175,7 +172,7 @@ class LoopyBelief { const std::map& allDiscreteKeys) const { StarGraphs starGraphs; VariableIndex varIndex(graph); ///< access to all factors of each node - for (Key key : varIndex | boost::adaptors::map_keys) { + for (const auto& [key, _] : varIndex) { // initialize to multiply with other unary factors later DecisionTreeFactor::shared_ptr prodOfUnaries; diff --git a/gtsam_unstable/examples/SmartRangeExample_plaza1.cpp b/gtsam_unstable/examples/SmartRangeExample_plaza1.cpp index 641855da0..0e2822e60 100644 --- a/gtsam_unstable/examples/SmartRangeExample_plaza1.cpp +++ b/gtsam_unstable/examples/SmartRangeExample_plaza1.cpp @@ -179,9 +179,9 @@ int main(int argc, char** argv) { landmarkEstimates.insert(i, predictedPose); // Check if there are range factors to be added - while (k < K && t >= boost::get<0>(triples[k])) { - size_t j = boost::get<1>(triples[k]); - double range = boost::get<2>(triples[k]); + while (k < K && t >= std::get<0>(triples[k])) { + size_t j = std::get<1>(triples[k]); + double range = std::get<2>(triples[k]); if (i > start) { if (smart && totalCount < minK) { try { diff --git a/gtsam_unstable/examples/SmartRangeExample_plaza2.cpp b/gtsam_unstable/examples/SmartRangeExample_plaza2.cpp index 1c403f142..9a2863d68 100644 --- a/gtsam_unstable/examples/SmartRangeExample_plaza2.cpp +++ b/gtsam_unstable/examples/SmartRangeExample_plaza2.cpp @@ -160,9 +160,9 @@ int main(int argc, char** argv) { landmarkEstimates.insert(i, predictedPose); // Check if there are range factors to be added - while (k < K && t >= boost::get<0>(triples[k])) { - size_t j = boost::get<1>(triples[k]); - double range = boost::get<2>(triples[k]); + while (k < K && t >= std::get<0>(triples[k])) { + size_t j = std::get<1>(triples[k]); + double range = std::get<2>(triples[k]); RangeFactor factor(i, symbol('L', j), range, rangeNoise); // Throw out obvious outliers based on current landmark estimates Vector error = factor.unwhitenedError(landmarkEstimates); diff --git a/gtsam_unstable/linear/LPInitSolver.cpp b/gtsam_unstable/linear/LPInitSolver.cpp index 8c3df3132..9f12d670e 100644 --- a/gtsam_unstable/linear/LPInitSolver.cpp +++ b/gtsam_unstable/linear/LPInitSolver.cpp @@ -66,7 +66,7 @@ GaussianFactorGraph::shared_ptr LPInitSolver::buildInitOfInitGraph() const { // create factor ||x||^2 and add to the graph const KeyDimMap& constrainedKeyDim = lp_.constrainedKeyDimMap(); - for (Key key : constrainedKeyDim | boost::adaptors::map_keys) { + for (const auto& [key, _] : constrainedKeyDim) { size_t dim = constrainedKeyDim.at(key); initGraph->push_back( JacobianFactor(key, Matrix::Identity(dim, dim), Vector::Zero(dim))); @@ -107,4 +107,4 @@ InequalityFactorGraph LPInitSolver::addSlackVariableToInequalities( return slackInequalities; } -} \ No newline at end of file +} diff --git a/timing/timeIncremental.cpp b/timing/timeIncremental.cpp index b8bcca5e7..a1948f115 100644 --- a/timing/timeIncremental.cpp +++ b/timing/timeIncremental.cpp @@ -27,7 +27,6 @@ #include #include #include -#include using namespace std; using namespace gtsam; @@ -225,9 +224,14 @@ int main(int argc, char *argv[]) { try { Marginals marginals(graph, values); int i=0; - for (Key key1: boost::adaptors::reverse(values.keys())) { + // Assign the keyvector to a named variable + auto keys = values.keys(); + // Iterate over it in reverse + for (auto it1 = keys.rbegin(); it1 != keys.rend(); ++it1) { + Key key1 = *it1; int j=0; - for (Key key2: boost::adaptors::reverse(values.keys())) { + for (auto it2 = keys.rbegin(); it2 != keys.rend(); ++it2) { + Key key2 = *it2; if(i != j) { gttic_(jointMarginalInformation); KeyVector keys(2);