diff --git a/gtsam/inference/BayesTree-inst.h b/gtsam/inference/BayesTree-inst.h index 82899b299..055971a82 100644 --- a/gtsam/inference/BayesTree-inst.h +++ b/gtsam/inference/BayesTree-inst.h @@ -26,11 +26,8 @@ #include #include -#include #include -using boost::assign::cref_list_of; - namespace gtsam { /* ************************************************************************* */ @@ -281,8 +278,8 @@ namespace gtsam { FactorGraphType cliqueMarginal = clique->marginal2(function); // Now, marginalize out everything that is not variable j - BayesNetType marginalBN = *cliqueMarginal.marginalMultifrontalBayesNet( - Ordering(cref_list_of<1,Key>(j)), function); + BayesNetType marginalBN = + *cliqueMarginal.marginalMultifrontalBayesNet(Ordering{j}, function); // The Bayes net should contain only one conditional for variable j, so return it return marginalBN.front(); @@ -403,7 +400,7 @@ namespace gtsam { } // now, marginalize out everything that is not variable j1 or j2 - return p_BC1C2.marginalMultifrontalBayesNet(Ordering(cref_list_of<2,Key>(j1)(j2)), function); + return p_BC1C2.marginalMultifrontalBayesNet(Ordering{j1, j2}, function); } /* ************************************************************************* */ diff --git a/gtsam/linear/HessianFactor.cpp b/gtsam/linear/HessianFactor.cpp index 8646a9cae..c5cde2c15 100644 --- a/gtsam/linear/HessianFactor.cpp +++ b/gtsam/linear/HessianFactor.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -41,7 +40,6 @@ #include using namespace std; -using namespace boost::assign; namespace br { using namespace boost::range; using namespace boost::adaptors; @@ -49,6 +47,9 @@ using namespace boost::adaptors; namespace gtsam { +// Typedefs used in constructors below. +using Dims = std::vector; + /* ************************************************************************* */ void HessianFactor::Allocate(const Scatter& scatter) { gttic(HessianFactor_Allocate); @@ -74,14 +75,14 @@ HessianFactor::HessianFactor(const Scatter& scatter) { /* ************************************************************************* */ HessianFactor::HessianFactor() : - info_(cref_list_of<1>(1)) { + info_(Dims{1}) { assert(info_.rows() == 1); constantTerm() = 0.0; } /* ************************************************************************* */ -HessianFactor::HessianFactor(Key j, const Matrix& G, const Vector& g, double f) : - GaussianFactor(cref_list_of<1>(j)), info_(cref_list_of<2>(G.cols())(1)) { +HessianFactor::HessianFactor(Key j, const Matrix& G, const Vector& g, double f) + : GaussianFactor(KeyVector{j}), info_(Dims{G.cols(), 1}) { if (G.rows() != G.cols() || G.rows() != g.size()) throw invalid_argument( "Attempting to construct HessianFactor with inconsistent matrix and/or vector dimensions"); @@ -93,8 +94,8 @@ HessianFactor::HessianFactor(Key j, const Matrix& G, const Vector& g, double f) /* ************************************************************************* */ // error is 0.5*(x-mu)'*inv(Sigma)*(x-mu) = 0.5*(x'*G*x - 2*x'*G*mu + mu'*G*mu) // where G = inv(Sigma), g = G*mu, f = mu'*G*mu = mu'*g -HessianFactor::HessianFactor(Key j, const Vector& mu, const Matrix& Sigma) : - GaussianFactor(cref_list_of<1>(j)), info_(cref_list_of<2>(Sigma.cols())(1)) { +HessianFactor::HessianFactor(Key j, const Vector& mu, const Matrix& Sigma) + : GaussianFactor(KeyVector{j}), info_(Dims{Sigma.cols(), 1}) { if (Sigma.rows() != Sigma.cols() || Sigma.rows() != mu.size()) throw invalid_argument( "Attempting to construct HessianFactor with inconsistent matrix and/or vector dimensions"); @@ -107,8 +108,8 @@ HessianFactor::HessianFactor(Key j, const Vector& mu, const Matrix& Sigma) : HessianFactor::HessianFactor(Key j1, Key j2, const Matrix& G11, const Matrix& G12, const Vector& g1, const Matrix& G22, const Vector& g2, double f) : - GaussianFactor(cref_list_of<2>(j1)(j2)), info_( - cref_list_of<3>(G11.cols())(G22.cols())(1)) { + GaussianFactor(KeyVector{j1,j2}), info_( + Dims{G11.cols(),G22.cols(),1}) { info_.setDiagonalBlock(0, G11); info_.setOffDiagonalBlock(0, 1, G12); info_.setDiagonalBlock(1, G22); @@ -121,8 +122,8 @@ HessianFactor::HessianFactor(Key j1, Key j2, Key j3, const Matrix& G11, const Matrix& G12, const Matrix& G13, const Vector& g1, const Matrix& G22, const Matrix& G23, const Vector& g2, const Matrix& G33, const Vector& g3, double f) : - GaussianFactor(cref_list_of<3>(j1)(j2)(j3)), info_( - cref_list_of<4>(G11.cols())(G22.cols())(G33.cols())(1)) { + GaussianFactor(KeyVector{j1,j2,j3}), info_( + Dims{G11.cols(),G22.cols(),G33.cols(),1}) { if (G11.rows() != G11.cols() || G11.rows() != G12.rows() || G11.rows() != G13.rows() || G11.rows() != g1.size() || G22.cols() != G12.cols() || G33.cols() != G13.cols() diff --git a/gtsam/linear/JacobianFactor.cpp b/gtsam/linear/JacobianFactor.cpp index 635476687..84083c4bc 100644 --- a/gtsam/linear/JacobianFactor.cpp +++ b/gtsam/linear/JacobianFactor.cpp @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -44,13 +43,16 @@ #include using namespace std; -using namespace boost::assign; namespace gtsam { +// Typedefs used in constructors below. +using Dims = std::vector; +using Pairs = std::vector>; + /* ************************************************************************* */ JacobianFactor::JacobianFactor() : - Ab_(cref_list_of<1>(1), 0) { + Ab_(Dims{1}, 0) { getb().setZero(); } @@ -68,29 +70,27 @@ JacobianFactor::JacobianFactor(const GaussianFactor& gf) { /* ************************************************************************* */ JacobianFactor::JacobianFactor(const Vector& b_in) : - Ab_(cref_list_of<1>(1), b_in.size()) { + Ab_(Dims{1}, b_in.size()) { getb() = b_in; } /* ************************************************************************* */ JacobianFactor::JacobianFactor(Key i1, const Matrix& A1, const Vector& b, const SharedDiagonal& model) { - fillTerms(cref_list_of<1>(make_pair(i1, A1)), b, model); + fillTerms(Pairs{{i1, A1}}, b, model); } /* ************************************************************************* */ JacobianFactor::JacobianFactor(const Key i1, const Matrix& A1, Key i2, const Matrix& A2, const Vector& b, const SharedDiagonal& model) { - fillTerms(cref_list_of<2>(make_pair(i1, A1))(make_pair(i2, A2)), b, model); + fillTerms(Pairs{{i1, A1}, {i2, A2}}, b, model); } /* ************************************************************************* */ JacobianFactor::JacobianFactor(const Key i1, const Matrix& A1, Key i2, const Matrix& A2, Key i3, const Matrix& A3, const Vector& b, const SharedDiagonal& model) { - fillTerms( - cref_list_of<3>(make_pair(i1, A1))(make_pair(i2, A2))(make_pair(i3, A3)), - b, model); + fillTerms(Pairs{{i1, A1}, {i2, A2}, {i3, A3}}, b, model); } /* ************************************************************************* */ diff --git a/gtsam/nonlinear/NonlinearFactor.h b/gtsam/nonlinear/NonlinearFactor.h index f6517d281..622d4de37 100644 --- a/gtsam/nonlinear/NonlinearFactor.h +++ b/gtsam/nonlinear/NonlinearFactor.h @@ -29,12 +29,9 @@ #include // boost::index_sequence #include -#include namespace gtsam { -using boost::assign::cref_list_of; - /* ************************************************************************* */ /** diff --git a/gtsam/sfm/ShonanGaugeFactor.h b/gtsam/sfm/ShonanGaugeFactor.h index d6240b1c4..4dc5b285e 100644 --- a/gtsam/sfm/ShonanGaugeFactor.h +++ b/gtsam/sfm/ShonanGaugeFactor.h @@ -59,7 +59,7 @@ public: */ ShonanGaugeFactor(Key key, size_t p, size_t d = 3, boost::optional gamma = boost::none) - : NonlinearFactor(boost::assign::cref_list_of<1>(key)) { + : NonlinearFactor(KeyVector{key}) { if (p < d) { throw std::invalid_argument("ShonanGaugeFactor must have p>=d."); } diff --git a/gtsam/symbolic/SymbolicFactor.h b/gtsam/symbolic/SymbolicFactor.h index 767998d22..91dbe3464 100644 --- a/gtsam/symbolic/SymbolicFactor.h +++ b/gtsam/symbolic/SymbolicFactor.h @@ -55,27 +55,27 @@ namespace gtsam { /** Construct unary factor */ explicit SymbolicFactor(Key j) : - Base(boost::assign::cref_list_of<1>(j)) {} + Base(KeyVector{j}) {} /** Construct binary factor */ SymbolicFactor(Key j1, Key j2) : - Base(boost::assign::cref_list_of<2>(j1)(j2)) {} + Base(KeyVector{j1, j2}) {} /** Construct ternary factor */ SymbolicFactor(Key j1, Key j2, Key j3) : - Base(boost::assign::cref_list_of<3>(j1)(j2)(j3)) {} + Base(KeyVector{j1, j2, j3}) {} /** Construct 4-way factor */ SymbolicFactor(Key j1, Key j2, Key j3, Key j4) : - Base(boost::assign::cref_list_of<4>(j1)(j2)(j3)(j4)) {} + Base(KeyVector{j1, j2, j3, j4}) {} /** Construct 5-way factor */ SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5) : - Base(boost::assign::cref_list_of<5>(j1)(j2)(j3)(j4)(j5)) {} + Base(KeyVector{j1, j2, j3, j4, j5}) {} /** Construct 6-way factor */ SymbolicFactor(Key j1, Key j2, Key j3, Key j4, Key j5, Key j6) : - Base(boost::assign::cref_list_of<6>(j1)(j2)(j3)(j4)(j5)(j6)) {} + Base(KeyVector{j1, j2, j3, j4, j5, j6}) {} /** Create symbolic version of any factor */ explicit SymbolicFactor(const Factor& factor) : Base(factor.keys()) {}