functional
parent
4ffc55d8a2
commit
d73ae62d78
|
|
@ -9,6 +9,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <functional>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include "EliminationTree.h"
|
#include "EliminationTree.h"
|
||||||
|
|
||||||
|
|
@ -52,9 +53,12 @@ namespace gtsam {
|
||||||
EliminationTree<FG>::EliminationTree(const OrderedGraphs& graphs) :
|
EliminationTree<FG>::EliminationTree(const OrderedGraphs& graphs) :
|
||||||
nrVariables_(graphs.size()), nodes_(nrVariables_) {
|
nrVariables_(graphs.size()), nodes_(nrVariables_) {
|
||||||
|
|
||||||
// Create a temporary map from key to ordering index
|
// Get ordering by (map first graphs)
|
||||||
Ordering ordering;
|
Ordering ordering;
|
||||||
transform(graphs.begin(), graphs.end(), std::back_inserter(ordering), getName);
|
transform(graphs.begin(), graphs.end(), back_inserter(ordering),
|
||||||
|
_Select1st<typename OrderedGraphs::value_type> ());
|
||||||
|
|
||||||
|
// Create a temporary map from key to ordering index
|
||||||
IndexTable<Symbol> indexTable(ordering);
|
IndexTable<Symbol> indexTable(ordering);
|
||||||
|
|
||||||
// Go over the collection in reverse elimination order
|
// Go over the collection in reverse elimination order
|
||||||
|
|
@ -68,7 +72,7 @@ namespace gtsam {
|
||||||
EliminationTree<FG>::EliminationTree(FG& fg, const Ordering& ordering) :
|
EliminationTree<FG>::EliminationTree(FG& fg, const Ordering& ordering) :
|
||||||
nrVariables_(ordering.size()), nodes_(nrVariables_) {
|
nrVariables_(ordering.size()), nodes_(nrVariables_) {
|
||||||
|
|
||||||
// Loop over all variables and get factors that have it
|
// Loop over all variables and get factors that are connected
|
||||||
OrderedGraphs graphs;
|
OrderedGraphs graphs;
|
||||||
BOOST_FOREACH(const Symbol& key, ordering) {
|
BOOST_FOREACH(const Symbol& key, ordering) {
|
||||||
// TODO: a collection of factors is a factor graph and this should be returned
|
// TODO: a collection of factors is a factor graph and this should be returned
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace gtsam {
|
||||||
/**
|
/**
|
||||||
* An elimination tree (see Gilbert01bit) associated with a factorg raph and an ordering
|
* An elimination tree (see Gilbert01bit) associated with a factorg raph and an ordering
|
||||||
* is a cluster-tree where there is one node j for each variable, and the parent of each node
|
* is a cluster-tree where there is one node j for each variable, and the parent of each node
|
||||||
* corresponds to the first variable in the ordering that variable j is connected to.
|
* corresponds to the first variable up the ordering in the Cholesky factor that j is connected to.
|
||||||
*/
|
*/
|
||||||
template<class FG>
|
template<class FG>
|
||||||
class EliminationTree: public ClusterTree<FG> {
|
class EliminationTree: public ClusterTree<FG> {
|
||||||
|
|
@ -41,10 +41,6 @@ namespace gtsam {
|
||||||
typedef std::vector<sharedNode> Nodes;
|
typedef std::vector<sharedNode> Nodes;
|
||||||
Nodes nodes_;
|
Nodes nodes_;
|
||||||
|
|
||||||
static inline Symbol getName(const NamedGraph& namedGraph) {
|
|
||||||
return namedGraph.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add a factor graph fragment with given frontal key into the tree. Assumes
|
* add a factor graph fragment with given frontal key into the tree. Assumes
|
||||||
* parent node was already added (will throw exception if not).
|
* parent node was already added (will throw exception if not).
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue