diff --git a/gtsam/discrete/DecisionTree-inl.h b/gtsam/discrete/DecisionTree-inl.h index a9953d506..057f014bf 100644 --- a/gtsam/discrete/DecisionTree-inl.h +++ b/gtsam/discrete/DecisionTree-inl.h @@ -27,6 +27,7 @@ #include #include #include +using boost::assign::operator+=; #include #include @@ -37,8 +38,6 @@ namespace gtsam { - using namespace boost::assign; - /*********************************************************************************/ // Node /*********************************************************************************/ diff --git a/gtsam/discrete/DiscreteConditional.cpp b/gtsam/discrete/DiscreteConditional.cpp index f9d3823d6..34cf016ec 100644 --- a/gtsam/discrete/DiscreteConditional.cpp +++ b/gtsam/discrete/DiscreteConditional.cpp @@ -66,7 +66,7 @@ namespace gtsam { Index j = (key); size_t value = parentsValues.at(j); pFS = pFS.choose(j, value); - } catch (exception& e) { + } catch (exception&) { throw runtime_error( "DiscreteConditional::choose: parent value missing"); }; diff --git a/gtsam/discrete/DiscreteFactorGraph.cpp b/gtsam/discrete/DiscreteFactorGraph.cpp index 0d5e01c29..4726c752f 100644 --- a/gtsam/discrete/DiscreteFactorGraph.cpp +++ b/gtsam/discrete/DiscreteFactorGraph.cpp @@ -64,7 +64,7 @@ namespace gtsam { } /* ************************************************************************* */ - pair // + std::pair // EliminateDiscrete(const FactorGraph& factors, size_t num) { // PRODUCT: multiply all factors @@ -87,7 +87,7 @@ namespace gtsam { toc(3, "divide"); tictoc_finishedIteration(); - return make_pair(cond, sum); + return std::make_pair(cond, sum); } /* ************************************************************************* */ diff --git a/gtsam/inference/BayesNet-inl.h b/gtsam/inference/BayesNet-inl.h index 88b386b72..b668a7741 100644 --- a/gtsam/inference/BayesNet-inl.h +++ b/gtsam/inference/BayesNet-inl.h @@ -24,20 +24,20 @@ #include #include // for += -using namespace boost::assign; +using boost::assign::operator+=; #include #include namespace gtsam { - /* ************************************************************************* */ - template - void BayesNet::print(const std::string& s) const { - std::cout << s; - BOOST_REVERSE_FOREACH(sharedConditional conditional,conditionals_) - conditional->print(); - } + /* ************************************************************************* */ + template + void BayesNet::print(const std::string& s) const { + std::cout << s; + BOOST_REVERSE_FOREACH(sharedConditional conditional, conditionals_) + conditional->print(); + } /* ************************************************************************* */ template diff --git a/gtsam/inference/BayesTree-inl.h b/gtsam/inference/BayesTree-inl.h index 0100bdd73..28f5e10cc 100644 --- a/gtsam/inference/BayesTree-inl.h +++ b/gtsam/inference/BayesTree-inl.h @@ -26,14 +26,17 @@ #include #include -#include -#include // for operator += -#include - #include #include #include +#include +#include // for operator += +using boost::assign::operator+=; +#include + +namespace lam = boost::lambda; + namespace gtsam { /* ************************************************************************* */ @@ -328,7 +331,7 @@ namespace gtsam { printf("WARNING: BayesTree.print encountered a forest...\n"); return; } - std::cout << s << ": clique size == " << size() << ", node size == " << nodes_.size() << std::endl; + std::cout << s << ": clique size == " << size() << ", node size == " << nodes_.size() << std::endl; if (nodes_.empty()) return; root_->printTree(""); } diff --git a/gtsam/inference/ClusterTree-inl.h b/gtsam/inference/ClusterTree-inl.h index 0a0b9e64e..267602eea 100644 --- a/gtsam/inference/ClusterTree-inl.h +++ b/gtsam/inference/ClusterTree-inl.h @@ -26,8 +26,6 @@ namespace gtsam { - using namespace std; - /* ************************************************************************* * * Cluster * ************************************************************************* */ @@ -73,19 +71,19 @@ namespace gtsam { /* ************************************************************************* */ template - void ClusterTree::Cluster::print(const string& indent) const { - cout << indent; + void ClusterTree::Cluster::print(const std::string& indent) const { + std::cout << indent; BOOST_FOREACH(const Index key, frontal) - cout << key << " "; - cout << ": "; + std::cout << key << " "; + std::cout << ": "; BOOST_FOREACH(const Index key, separator) - cout << key << " "; - cout << endl; + std::cout << key << " "; + std::cout << std::endl; } /* ************************************************************************* */ template - void ClusterTree::Cluster::printTree(const string& indent) const { + void ClusterTree::Cluster::printTree(const std::string& indent) const { print(indent); BOOST_FOREACH(const shared_ptr& child, children_) child->printTree(indent + " "); @@ -95,8 +93,8 @@ namespace gtsam { * ClusterTree * ************************************************************************* */ template - void ClusterTree::print(const string& str) const { - cout << str << endl; + void ClusterTree::print(const std::string& str) const { + std::cout << str << std::endl; if (root_) root_->printTree(""); } diff --git a/gtsam/inference/FactorGraph-inl.h b/gtsam/inference/FactorGraph-inl.h index 3451b6ed4..b7c3f81a5 100644 --- a/gtsam/inference/FactorGraph-inl.h +++ b/gtsam/inference/FactorGraph-inl.h @@ -34,17 +34,15 @@ #include #include -using namespace std; - namespace gtsam { /* ************************************************************************* */ template - void FactorGraph::print(const string& s) const { - cout << s << endl; - cout << "size: " << size() << endl; + void FactorGraph::print(const std::string& s) const { + std::cout << s << std::endl; + std::cout << "size: " << size() << std::endl; for (size_t i = 0; i < factors_.size(); i++) { - stringstream ss; + std::stringstream ss; ss << "factor " << i << ": "; if (factors_[i] != NULL) factors_[i]->print(ss.str()); } @@ -79,7 +77,7 @@ namespace gtsam { /* ************************************************************************* */ template void FactorGraph::replace(size_t index, sharedFactor factor) { - if (index >= factors_.size()) throw invalid_argument(boost::str( + if (index >= factors_.size()) throw std::invalid_argument(boost::str( boost::format("Factor graph does not contain a factor with index %d.") % index)); // Replace the factor @@ -115,7 +113,7 @@ namespace gtsam { /* ************************************************************************* */ template void _FactorGraph_BayesTree_adder( - vector::sharedFactor>& factors, + std::vector::sharedFactor>& factors, const typename BayesTree::sharedClique& clique) { if(clique) { diff --git a/gtsam/inference/GenericMultifrontalSolver-inl.h b/gtsam/inference/GenericMultifrontalSolver-inl.h index 84ca937fa..40a70bfd7 100644 --- a/gtsam/inference/GenericMultifrontalSolver-inl.h +++ b/gtsam/inference/GenericMultifrontalSolver-inl.h @@ -21,8 +21,6 @@ #include #include -using namespace std; - namespace gtsam { /* ************************************************************************* */ @@ -69,7 +67,7 @@ namespace gtsam { // We currently have code written only for computing the - if (js.size() != 2) throw domain_error( + if (js.size() != 2) throw std::domain_error( "*MultifrontalSolver::joint(js) currently can only compute joint marginals\n" "for exactly two variables. You can call marginal to compute the\n" "marginal for one variable. *SequentialSolver::joint(js) can compute the\n" diff --git a/gtsam/inference/ISAM-inl.h b/gtsam/inference/ISAM-inl.h index 5d72f396c..c1252f1b0 100644 --- a/gtsam/inference/ISAM-inl.h +++ b/gtsam/inference/ISAM-inl.h @@ -19,7 +19,6 @@ #include #include // for operator += -using namespace boost::assign; #include #include @@ -27,8 +26,6 @@ using namespace boost::assign; namespace gtsam { - using namespace std; - /* ************************************************************************* */ template ISAM::ISAM() : BayesTree() {} diff --git a/gtsam/inference/JunctionTree-inl.h b/gtsam/inference/JunctionTree-inl.h index c1add38bf..1d647ef88 100644 --- a/gtsam/inference/JunctionTree-inl.h +++ b/gtsam/inference/JunctionTree-inl.h @@ -79,7 +79,7 @@ namespace gtsam { // Two stages - first build an array of the lowest-ordered variable in each // factor and find the last variable to be eliminated. - vector lowestOrdered(fg.size(), numeric_limits::max()); + std::vector lowestOrdered(fg.size(), std::numeric_limits::max()); Index maxVar = 0; for(size_t i=0; i > targets(maxVar+1); + std::vector > targets(maxVar+1); for(size_t i=0; i::max()) + if(lowestOrdered[i] != std::numeric_limits::max()) targets[lowestOrdered[i]].push_back(i); // Now call the recursive distributeFactors @@ -141,7 +141,7 @@ namespace gtsam { /* ************************************************************************* */ template - pair::BTClique::shared_ptr, + std::pair::BTClique::shared_ptr, typename FG::sharedFactor> JunctionTree::eliminateOneClique( typename FG::Eliminate function, const boost::shared_ptr& current) const { @@ -151,9 +151,9 @@ namespace gtsam { fg.push_back(*current); // add the local factors // receive the factors from the child and its clique point - list children; + std::list children; BOOST_FOREACH(const boost::shared_ptr& child, current->children()) { - pair tree_factor( + std::pair tree_factor( eliminateOneClique(function, child)); children.push_back(tree_factor.first); fg.push_back(tree_factor.second); @@ -181,7 +181,7 @@ namespace gtsam { } toc(3, "Update tree"); - return make_pair(new_clique, eliminated.second); + return std::make_pair(new_clique, eliminated.second); } /* ************************************************************************* */ @@ -190,9 +190,9 @@ namespace gtsam { typename FG::Eliminate function) const { if (this->root()) { tic(2, "JT eliminate"); - pair ret = + std::pair ret = this->eliminateOneClique(function, this->root()); - if (ret.second->size() != 0) throw runtime_error( + if (ret.second->size() != 0) throw std::runtime_error( "JuntionTree::eliminate: elimination failed because of factors left over!"); toc(2, "JT eliminate"); return ret.first; diff --git a/gtsam/inference/graph-inl.h b/gtsam/inference/graph-inl.h index c4485cf5c..b086fd2fb 100644 --- a/gtsam/inference/graph-inl.h +++ b/gtsam/inference/graph-inl.h @@ -24,8 +24,6 @@ #include -using namespace std; - #define FOREACH_PAIR( KEY, VAL, COL) BOOST_FOREACH (boost::tie(KEY,VAL),COL) namespace gtsam { @@ -66,7 +64,7 @@ SDGraph toBoostGraph(const G& graph) { // convert the factor graph to boost graph SDGraph g; typedef typename boost::graph_traits >::vertex_descriptor BoostVertex; - map key2vertex; + std::map key2vertex; BoostVertex v1, v2; typename G::const_iterator itFactor; @@ -108,7 +106,7 @@ boost::tuple > predecessorMap2Graph(const PredecessorMap& p_map) { G g; - map key2vertex; + std::map key2vertex; V v1, v2, root; KEY child, parent; bool foundRoot = false; diff --git a/gtsam/nonlinear/ISAM2-impl.cpp b/gtsam/nonlinear/ISAM2-impl.cpp index 05f42ad78..509143b0b 100644 --- a/gtsam/nonlinear/ISAM2-impl.cpp +++ b/gtsam/nonlinear/ISAM2-impl.cpp @@ -23,6 +23,8 @@ #include #include +using namespace std; + namespace gtsam { /* ************************************************************************* */ diff --git a/gtsam/nonlinear/ISAM2-impl.h b/gtsam/nonlinear/ISAM2-impl.h index 34573f0c5..51b613b86 100644 --- a/gtsam/nonlinear/ISAM2-impl.h +++ b/gtsam/nonlinear/ISAM2-impl.h @@ -22,8 +22,6 @@ namespace gtsam { -using namespace std; - struct ISAM2::Impl { struct PartialSolveResult { @@ -49,7 +47,7 @@ struct ISAM2::Impl { * @param keyFormatter Formatter for printing nonlinear keys during debugging */ static void AddVariables(const Values& newTheta, Values& theta, Permuted& delta, - Permuted& deltaNewton, Permuted& deltaGradSearch, vector& replacedKeys, + Permuted& deltaNewton, Permuted& deltaGradSearch, std::vector& replacedKeys, Ordering& ordering, Base::Nodes& nodes, const KeyFormatter& keyFormatter = DefaultKeyFormatter); /** @@ -88,7 +86,7 @@ struct ISAM2::Impl { * * Alternatively could we trace up towards the root for each variable here? */ - static void FindAll(ISAM2Clique::shared_ptr clique, FastSet& keys, const vector& markedMask); + static void FindAll(ISAM2Clique::shared_ptr clique, FastSet& keys, const std::vector& markedMask); /** * Apply expmap to the given values, but only for indices appearing in diff --git a/gtsam/nonlinear/ISAM2-inl.h b/gtsam/nonlinear/ISAM2-inl.h index 3ca82051d..3520ffb84 100644 --- a/gtsam/nonlinear/ISAM2-inl.h +++ b/gtsam/nonlinear/ISAM2-inl.h @@ -25,8 +25,6 @@ namespace gtsam { -using namespace std; - /* ************************************************************************* */ template VALUE ISAM2::calculateEstimate(Key key) const { @@ -39,7 +37,7 @@ VALUE ISAM2::calculateEstimate(Key key) const { namespace internal { template void optimizeWildfire(const boost::shared_ptr& clique, double threshold, - vector& changed, const vector& replaced, Permuted& delta, int& count) { + std::vector& changed, const std::vector& replaced, Permuted& delta, int& count) { // if none of the variables in this clique (frontal and separator!) changed // significantly, then by the running intersection property, none of the // cliques in the children need to be processed @@ -68,7 +66,7 @@ void optimizeWildfire(const boost::shared_ptr& clique, double threshold, if(recalculate) { // Temporary copy of the original values, to check how much they change - vector originalValues((*clique)->nrFrontals()); + std::vector originalValues((*clique)->nrFrontals()); GaussianConditional::const_iterator it; for(it = (*clique)->beginFrontals(); it!=(*clique)->endFrontals(); it++) { originalValues[it - (*clique)->beginFrontals()] = delta[*it]; @@ -116,8 +114,8 @@ void optimizeWildfire(const boost::shared_ptr& clique, double threshold, /* ************************************************************************* */ template -int optimizeWildfire(const boost::shared_ptr& root, double threshold, const vector& keys, Permuted& delta) { - vector changed(keys.size(), false); +int optimizeWildfire(const boost::shared_ptr& root, double threshold, const std::vector& keys, Permuted& delta) { + std::vector changed(keys.size(), false); int count = 0; // starting from the root, call optimize on each conditional if(root) diff --git a/gtsam/nonlinear/ISAM2.h b/gtsam/nonlinear/ISAM2.h index 2211122d8..a2ef3793b 100644 --- a/gtsam/nonlinear/ISAM2.h +++ b/gtsam/nonlinear/ISAM2.h @@ -246,7 +246,7 @@ struct ISAM2Clique : public BayesTreeCliqueBase >& result) : @@ -260,7 +260,7 @@ struct ISAM2Clique : public BayesTreeCliqueBaseclone() : Base::FactorType::shared_ptr()))); copy->gradientContribution_ = gradientContribution_; @@ -283,7 +283,7 @@ struct ISAM2Clique : public BayesTreeCliqueBaseprint(s + "Cached: "); else - cout << s << "Cached empty" << endl; + std::cout << s << "Cached empty" << std::endl; if(gradientContribution_.rows() != 0) gtsam::print(gradientContribution_, "Gradient contribution: "); } diff --git a/gtsam/nonlinear/NonlinearFactor.h b/gtsam/nonlinear/NonlinearFactor.h index 1d4d580b9..8251bff59 100644 --- a/gtsam/nonlinear/NonlinearFactor.h +++ b/gtsam/nonlinear/NonlinearFactor.h @@ -100,7 +100,7 @@ public: virtual void print(const std::string& s = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const { std::cout << s << "keys = { "; BOOST_FOREACH(Key key, this->keys()) { std::cout << keyFormatter(key) << " "; } - std::cout << "}" << endl; + std::cout << "}" << std::endl; } /** Check if two factors are equal */ diff --git a/gtsam/nonlinear/SuccessiveLinearizationOptimizer.h b/gtsam/nonlinear/SuccessiveLinearizationOptimizer.h index 156440f06..b4a7c3c21 100644 --- a/gtsam/nonlinear/SuccessiveLinearizationOptimizer.h +++ b/gtsam/nonlinear/SuccessiveLinearizationOptimizer.h @@ -104,7 +104,7 @@ public: return EliminateQR; default: - throw runtime_error("Nonlinear optimization parameter \"factorization\" is invalid"); + throw std::runtime_error("Nonlinear optimization parameter \"factorization\" is invalid"); break; } } diff --git a/gtsam/slam/ProjectionFactor.h b/gtsam/slam/ProjectionFactor.h index 179362a42..c6529a34f 100644 --- a/gtsam/slam/ProjectionFactor.h +++ b/gtsam/slam/ProjectionFactor.h @@ -97,8 +97,8 @@ namespace gtsam { } catch( CheiralityException& e) { if (H1) *H1 = zeros(2,6); if (H2) *H2 = zeros(2,3); - cout << e.what() << ": Landmark "<< DefaultKeyFormatter(this->key2()) << - " moved behind camera " << DefaultKeyFormatter(this->key1()) << endl; + std::cout << e.what() << ": Landmark "<< DefaultKeyFormatter(this->key2()) << + " moved behind camera " << DefaultKeyFormatter(this->key1()) << std::endl; return ones(2) * 2.0 * K_->fx(); } } diff --git a/gtsam_unstable/linear/iterative-inl.h b/gtsam_unstable/linear/iterative-inl.h index ee43abc77..c91e6f68a 100644 --- a/gtsam_unstable/linear/iterative-inl.h +++ b/gtsam_unstable/linear/iterative-inl.h @@ -22,8 +22,6 @@ #include #include -using namespace std; - namespace gtsam { /* ************************************************************************* */