Got rid of Boost cref_list_of
parent
017cd8f8a2
commit
313ab013d3
|
@ -26,11 +26,8 @@
|
|||
#include <gtsam/base/timing.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <fstream>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <boost/format.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
|
@ -41,7 +40,6 @@
|
|||
#include <limits>
|
||||
|
||||
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<Eigen::Index>;
|
||||
|
||||
/* ************************************************************************* */
|
||||
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()
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <gtsam/base/FastMap.h>
|
||||
#include <gtsam/base/cholesky.h>
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/array.hpp>
|
||||
|
@ -44,13 +43,16 @@
|
|||
#include <stdexcept>
|
||||
|
||||
using namespace std;
|
||||
using namespace boost::assign;
|
||||
|
||||
namespace gtsam {
|
||||
|
||||
// Typedefs used in constructors below.
|
||||
using Dims = std::vector<Eigen::Index>;
|
||||
using Pairs = std::vector<std::pair<Eigen::Index, Matrix>>;
|
||||
|
||||
/* ************************************************************************* */
|
||||
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);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
|
@ -29,12 +29,9 @@
|
|||
#include <gtsam/base/utilities.h> // boost::index_sequence
|
||||
|
||||
#include <boost/serialization/base_object.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
|
||||
namespace gtsam {
|
||||
|
||||
using boost::assign::cref_list_of;
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
*/
|
||||
ShonanGaugeFactor(Key key, size_t p, size_t d = 3,
|
||||
boost::optional<double> 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.");
|
||||
}
|
||||
|
|
|
@ -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()) {}
|
||||
|
|
Loading…
Reference in New Issue