Formatting only

release/4.3a0
dellaert 2015-06-21 12:57:26 -07:00
parent 67013cba05
commit 0d0a9e5b16
1 changed files with 105 additions and 104 deletions

View File

@ -13,19 +13,17 @@
#include <gtsam/base/FastVector.h> #include <gtsam/base/FastVector.h>
#include <gtsam/inference/Ordering.h> #include <gtsam/inference/Ordering.h>
namespace gtsam namespace gtsam {
{
/** /**
* A cluster-tree is associated with a factor graph and is defined as in Koller-Friedman: * A cluster-tree is associated with a factor graph and is defined as in Koller-Friedman:
* each node k represents a subset \f$ C_k \sub X \f$, and the tree is family preserving, in that * each node k represents a subset \f$ C_k \sub X \f$, and the tree is family preserving, in that
* each factor \f$ f_i \f$ is associated with a single cluster and \f$ scope(f_i) \sub C_k \f$. * each factor \f$ f_i \f$ is associated with a single cluster and \f$ scope(f_i) \sub C_k \f$.
* \nosubgrouping * \nosubgrouping
*/ */
template<class BAYESTREE, class GRAPH> template<class BAYESTREE, class GRAPH>
class ClusterTree class ClusterTree {
{ public:
public:
typedef GRAPH FactorGraphType; ///< The factor graph type typedef GRAPH FactorGraphType; ///< The factor graph type
typedef typename GRAPH::FactorType FactorType; ///< The type of factors typedef typename GRAPH::FactorType FactorType; ///< The type of factors
typedef ClusterTree<BAYESTREE, GRAPH> This; ///< This class typedef ClusterTree<BAYESTREE, GRAPH> This; ///< This class
@ -41,8 +39,10 @@ namespace gtsam
typedef FastVector<sharedFactor> Factors; typedef FastVector<sharedFactor> Factors;
typedef FastVector<boost::shared_ptr<Cluster> > Children; typedef FastVector<boost::shared_ptr<Cluster> > Children;
Cluster() {} Cluster() {
Cluster(Key key, const Factors& factors) : factors(factors) { }
Cluster(Key key, const Factors& factors) :
factors(factors) {
orderedFrontalKeys.push_back(key); orderedFrontalKeys.push_back(key);
} }
@ -51,10 +51,13 @@ namespace gtsam
Children children; ///< sub-trees Children children; ///< sub-trees
int problemSize_; int problemSize_;
int problemSize() const { return problemSize_; } int problemSize() const {
return problemSize_;
}
/** print this node */ /** print this node */
void print(const std::string& s = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const; void print(const std::string& s = "", const KeyFormatter& keyFormatter =
DefaultKeyFormatter) const;
}; };
typedef boost::shared_ptr<Cluster> sharedCluster; ///< Shared pointer to Cluster typedef boost::shared_ptr<Cluster> sharedCluster; ///< Shared pointer to Cluster
@ -64,7 +67,7 @@ namespace gtsam
/** concept check */ /** concept check */
GTSAM_CONCEPT_TESTABLE_TYPE(FactorType); GTSAM_CONCEPT_TESTABLE_TYPE(FactorType);
protected: protected:
FastVector<sharedNode> roots_; FastVector<sharedNode> roots_;
FastVector<sharedFactor> remainingFactors_; FastVector<sharedFactor> remainingFactors_;
@ -73,11 +76,11 @@ namespace gtsam
/** Copy constructor - makes a deep copy of the tree structure, but only pointers to factors are /** Copy constructor - makes a deep copy of the tree structure, but only pointers to factors are
* copied, factors are not cloned. */ * copied, factors are not cloned. */
ClusterTree(const This& other) { *this = other; } ClusterTree(const This& other) {*this = other;}
/// @} /// @}
public: public:
/// @name Testable /// @name Testable
/// @{ /// @{
@ -103,14 +106,14 @@ namespace gtsam
/// @{ /// @{
/** Return the set of roots (one for a tree, multiple for a forest) */ /** Return the set of roots (one for a tree, multiple for a forest) */
const FastVector<sharedNode>& roots() const { return roots_; } const FastVector<sharedNode>& roots() const {return roots_;}
/** Return the remaining factors that are not pulled into elimination */ /** Return the remaining factors that are not pulled into elimination */
const FastVector<sharedFactor>& remainingFactors() const { return remainingFactors_; } const FastVector<sharedFactor>& remainingFactors() const {return remainingFactors_;}
/// @} /// @}
protected: protected:
/// @name Details /// @name Details
/// Assignment operator - makes a deep copy of the tree structure, but only pointers to factors /// Assignment operator - makes a deep copy of the tree structure, but only pointers to factors
@ -122,9 +125,7 @@ namespace gtsam
/// @} /// @}
}; };
} }