From 0b13c437feb1c72d44d7a9070d7e4d65913f1ebc Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Fri, 26 Jul 2013 01:10:12 +0000 Subject: [PATCH] Updated print functions --- .../inference/EliminationTreeUnordered-inst.h | 4 ++-- gtsam/inference/JunctionTreeUnordered-inst.h | 19 +++++++++++++++++++ gtsam/inference/JunctionTreeUnordered.h | 6 ++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/gtsam/inference/EliminationTreeUnordered-inst.h b/gtsam/inference/EliminationTreeUnordered-inst.h index acb62d6cc..d1f2e79d7 100644 --- a/gtsam/inference/EliminationTreeUnordered-inst.h +++ b/gtsam/inference/EliminationTreeUnordered-inst.h @@ -68,9 +68,9 @@ namespace gtsam { std::cout << str << "(" << keyFormatter(key) << ")\n"; BOOST_FOREACH(const sharedFactor& factor, factors) { if(factor) - factor->print(str + "| "); + factor->print(str); else - std::cout << str << "| null factor\n"; + std::cout << str << "null factor\n"; } } diff --git a/gtsam/inference/JunctionTreeUnordered-inst.h b/gtsam/inference/JunctionTreeUnordered-inst.h index 898792e31..1702634e3 100644 --- a/gtsam/inference/JunctionTreeUnordered-inst.h +++ b/gtsam/inference/JunctionTreeUnordered-inst.h @@ -189,6 +189,25 @@ namespace gtsam { } } + /* ************************************************************************* */ + template + void JunctionTreeUnordered::Node::print( + const std::string& s, const KeyFormatter& keyFormatter) const + { + std::cout << s; + BOOST_FOREACH(Key j, keys) + std::cout << j << " "; + std::cout << "problemSize = " << problemSize_ << std::endl; + } + + /* ************************************************************************* */ + template + void JunctionTreeUnordered::print( + const std::string& s = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const + { + treeTraversal::PrintForest(*this, s, keyFormatter); + } + /* ************************************************************************* */ template template diff --git a/gtsam/inference/JunctionTreeUnordered.h b/gtsam/inference/JunctionTreeUnordered.h index 27dd22f14..015b605dc 100644 --- a/gtsam/inference/JunctionTreeUnordered.h +++ b/gtsam/inference/JunctionTreeUnordered.h @@ -68,6 +68,9 @@ namespace gtsam { Keys keys; ///< Frontal keys of this node Factors factors; ///< Factors associated with this node Children children; ///< sub-trees + + /** print this node */ + void print(const std::string& s = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const; }; typedef boost::shared_ptr sharedNode; ///< Shared pointer to Node @@ -112,6 +115,9 @@ namespace gtsam { std::pair, boost::shared_ptr > eliminate(const Eliminate& function) const; + /** Print the junction tree */ + void print(const std::string& s = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const; + /// @} /// @name Advanced Interface