Removed BOOST_REVERSE_FOREACH
parent
7ffcf765b5
commit
ef38e80857
|
@ -50,6 +50,7 @@
|
||||||
#include <boost/archive/binary_oarchive.hpp>
|
#include <boost/archive/binary_oarchive.hpp>
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/range/algorithm/set_algorithm.hpp>
|
#include <boost/range/algorithm/set_algorithm.hpp>
|
||||||
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
#include <boost/random.hpp>
|
#include <boost/random.hpp>
|
||||||
#include <boost/serialization/export.hpp>
|
#include <boost/serialization/export.hpp>
|
||||||
|
|
||||||
|
@ -421,9 +422,9 @@ void runIncremental()
|
||||||
//try {
|
//try {
|
||||||
// Marginals marginals(graph, values);
|
// Marginals marginals(graph, values);
|
||||||
// int i=0;
|
// int i=0;
|
||||||
// BOOST_REVERSE_FOREACH(Key key1, values.keys()) {
|
// for (Key key1: boost::adaptors::reverse(values.keys())) {
|
||||||
// int j=0;
|
// int j=0;
|
||||||
// BOOST_REVERSE_FOREACH(Key key2, values.keys()) {
|
// for (Key key12: boost::adaptors::reverse(values.keys())) {
|
||||||
// if(i != j) {
|
// if(i != j) {
|
||||||
// gttic_(jointMarginalInformation);
|
// gttic_(jointMarginalInformation);
|
||||||
// std::vector<Key> keys(2);
|
// std::vector<Key> keys(2);
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
#include <gtsam/discrete/DiscreteBayesNet.h>
|
#include <gtsam/discrete/DiscreteBayesNet.h>
|
||||||
#include <gtsam/discrete/DiscreteConditional.h>
|
#include <gtsam/discrete/DiscreteConditional.h>
|
||||||
#include <gtsam/inference/FactorGraph-inst.h>
|
#include <gtsam/inference/FactorGraph-inst.h>
|
||||||
|
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
@ -55,7 +57,7 @@ namespace gtsam {
|
||||||
DiscreteFactor::sharedValues DiscreteBayesNet::optimize() const {
|
DiscreteFactor::sharedValues DiscreteBayesNet::optimize() const {
|
||||||
// solve each node in turn in topological sort order (parents first)
|
// solve each node in turn in topological sort order (parents first)
|
||||||
DiscreteFactor::sharedValues result(new DiscreteFactor::Values());
|
DiscreteFactor::sharedValues result(new DiscreteFactor::Values());
|
||||||
BOOST_REVERSE_FOREACH (DiscreteConditional::shared_ptr conditional, *this)
|
for (auto conditional: boost::adaptors::reverse(*this))
|
||||||
conditional->solveInPlace(*result);
|
conditional->solveInPlace(*result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +66,7 @@ namespace gtsam {
|
||||||
DiscreteFactor::sharedValues DiscreteBayesNet::sample() const {
|
DiscreteFactor::sharedValues DiscreteBayesNet::sample() const {
|
||||||
// sample each node in turn in topological sort order (parents first)
|
// sample each node in turn in topological sort order (parents first)
|
||||||
DiscreteFactor::sharedValues result(new DiscreteFactor::Values());
|
DiscreteFactor::sharedValues result(new DiscreteFactor::Values());
|
||||||
BOOST_REVERSE_FOREACH(DiscreteConditional::shared_ptr conditional, *this)
|
for (auto conditional: boost::adaptors::reverse(*this))
|
||||||
conditional->sampleInPlace(*result);
|
conditional->sampleInPlace(*result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <gtsam/inference/FactorGraph-inst.h>
|
#include <gtsam/inference/FactorGraph-inst.h>
|
||||||
#include <gtsam/inference/BayesNet.h>
|
#include <gtsam/inference/BayesNet.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
@ -40,7 +40,7 @@ namespace gtsam {
|
||||||
std::ofstream of(s.c_str());
|
std::ofstream of(s.c_str());
|
||||||
of << "digraph G{\n";
|
of << "digraph G{\n";
|
||||||
|
|
||||||
BOOST_REVERSE_FOREACH(const sharedConditional& conditional, *this) {
|
for (auto conditional: boost::adaptors::reverse(*this)) {
|
||||||
typename CONDITIONAL::Frontals frontals = conditional->frontals();
|
typename CONDITIONAL::Frontals frontals = conditional->frontals();
|
||||||
Key me = frontals.front();
|
Key me = frontals.front();
|
||||||
typename CONDITIONAL::Parents parents = conditional->parents();
|
typename CONDITIONAL::Parents parents = conditional->parents();
|
||||||
|
|
|
@ -20,14 +20,11 @@
|
||||||
#include <gtsam/inference/FactorGraph-inst.h>
|
#include <gtsam/inference/FactorGraph-inst.h>
|
||||||
#include <gtsam/base/timing.h>
|
#include <gtsam/base/timing.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gtsam;
|
using namespace gtsam;
|
||||||
|
|
||||||
#define FOREACH_PAIR( KEY, VAL, COL) BOOST_FOREACH (boost::tie(KEY,VAL):COL)
|
|
||||||
#define REVERSE_FOREACH_PAIR( KEY, VAL, COL) BOOST_REVERSE_FOREACH (boost::tie(KEY,VAL),COL)
|
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
// Instantiate base class
|
// Instantiate base class
|
||||||
|
@ -52,7 +49,7 @@ namespace gtsam {
|
||||||
VectorValues soln(solutionForMissing); // possibly empty
|
VectorValues soln(solutionForMissing); // possibly empty
|
||||||
// (R*x)./sigmas = y by solving x=inv(R)*(y.*sigmas)
|
// (R*x)./sigmas = y by solving x=inv(R)*(y.*sigmas)
|
||||||
/** solve each node in turn in topological sort order (parents first)*/
|
/** solve each node in turn in topological sort order (parents first)*/
|
||||||
BOOST_REVERSE_FOREACH(const sharedConditional& cg, *this) {
|
for (auto cg: boost::adaptors::reverse(*this)) {
|
||||||
// i^th part of R*x=y, x=inv(R)*y
|
// 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:))
|
// (Rii*xi + R_i*x(i+1:))./si = yi <-> xi = inv(Rii)*(yi.*si - R_i*x(i+1:))
|
||||||
soln.insert(cg->solve(soln));
|
soln.insert(cg->solve(soln));
|
||||||
|
@ -88,7 +85,7 @@ namespace gtsam {
|
||||||
VectorValues result;
|
VectorValues result;
|
||||||
// TODO this looks pretty sketchy. result is passed as the parents argument
|
// TODO this looks pretty sketchy. result is passed as the parents argument
|
||||||
// as it's filled up by solving the gaussian conditionals.
|
// as it's filled up by solving the gaussian conditionals.
|
||||||
BOOST_REVERSE_FOREACH(const sharedConditional& cg, *this) {
|
for (auto cg: boost::adaptors::reverse(*this)) {
|
||||||
result.insert(cg->solveOtherRHS(result, rhs));
|
result.insert(cg->solveOtherRHS(result, rhs));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <boost/archive/text_iarchive.hpp>
|
#include <boost/archive/text_iarchive.hpp>
|
||||||
#include <boost/archive/text_oarchive.hpp>
|
#include <boost/archive/text_oarchive.hpp>
|
||||||
#include <boost/serialization/vector.hpp>
|
#include <boost/serialization/vector.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -569,7 +569,7 @@ void SubgraphPreconditioner::solve(const Vector& y, Vector &x) const
|
||||||
std::copy(y.data(), y.data() + y.rows(), x.data());
|
std::copy(y.data(), y.data() + y.rows(), x.data());
|
||||||
|
|
||||||
/* in place back substitute */
|
/* in place back substitute */
|
||||||
BOOST_REVERSE_FOREACH(const boost::shared_ptr<GaussianConditional> & cg, *Rc1_) {
|
for (auto cg: boost::adaptors::reverse(*Rc1_)) {
|
||||||
/* collect a subvector of x that consists of the parents of cg (S) */
|
/* collect a subvector of x that consists of the parents of cg (S) */
|
||||||
const Vector xParent = getSubvector(x, keyInfo_, FastVector<Key>(cg->beginParents(), cg->endParents()));
|
const Vector xParent = getSubvector(x, keyInfo_, FastVector<Key>(cg->beginParents(), cg->endParents()));
|
||||||
const Vector rhsFrontal = getSubvector(x, keyInfo_, FastVector<Key>(cg->beginFrontals(), cg->endFrontals()));
|
const Vector rhsFrontal = getSubvector(x, keyInfo_, FastVector<Key>(cg->beginFrontals(), cg->endFrontals()));
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
#include <gtsam/symbolic/SymbolicConditional.h>
|
#include <gtsam/symbolic/SymbolicConditional.h>
|
||||||
#include <gtsam/inference/FactorGraph-inst.h>
|
#include <gtsam/inference/FactorGraph-inst.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
@ -41,7 +40,7 @@ namespace gtsam {
|
||||||
std::ofstream of(s.c_str());
|
std::ofstream of(s.c_str());
|
||||||
of << "digraph G{\n";
|
of << "digraph G{\n";
|
||||||
|
|
||||||
BOOST_REVERSE_FOREACH(const sharedConditional& conditional, *this) {
|
for (auto conditional: boost::adaptors::reverse(*this)) {
|
||||||
SymbolicConditional::Frontals frontals = conditional->frontals();
|
SymbolicConditional::Frontals frontals = conditional->frontals();
|
||||||
Key me = frontals.front();
|
Key me = frontals.front();
|
||||||
SymbolicConditional::Parents parents = conditional->parents();
|
SymbolicConditional::Parents parents = conditional->parents();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <boost/archive/binary_oarchive.hpp>
|
#include <boost/archive/binary_oarchive.hpp>
|
||||||
#include <boost/archive/binary_iarchive.hpp>
|
#include <boost/archive/binary_iarchive.hpp>
|
||||||
#include <boost/serialization/export.hpp>
|
#include <boost/serialization/export.hpp>
|
||||||
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gtsam;
|
using namespace gtsam;
|
||||||
|
@ -225,9 +226,9 @@ int main(int argc, char *argv[]) {
|
||||||
try {
|
try {
|
||||||
Marginals marginals(graph, values);
|
Marginals marginals(graph, values);
|
||||||
int i=0;
|
int i=0;
|
||||||
BOOST_REVERSE_FOREACH(Key key1, values.keys()) {
|
for (Key key1: boost::adaptors::reverse(values.keys())) {
|
||||||
int j=0;
|
int j=0;
|
||||||
BOOST_REVERSE_FOREACH(Key key2, values.keys()) {
|
for (Key key2: boost::adaptors::reverse(values.keys())) {
|
||||||
if(i != j) {
|
if(i != j) {
|
||||||
gttic_(jointMarginalInformation);
|
gttic_(jointMarginalInformation);
|
||||||
std::vector<Key> keys(2);
|
std::vector<Key> keys(2);
|
||||||
|
|
Loading…
Reference in New Issue