diff --git a/inference/BayesNet-inl.h b/inference/BayesNet-inl.h index 53d60b68b..633beb7f8 100644 --- a/inference/BayesNet-inl.h +++ b/inference/BayesNet-inl.h @@ -17,6 +17,8 @@ #pragma once +#include + #include #include #include @@ -28,40 +30,36 @@ #include // for += using namespace boost::assign; -#include -//#include "FactorGraph-inl.h" -#include "Conditional.h" - using namespace std; namespace gtsam { /* ************************************************************************* */ - template - void BayesNet::print(const string& s) const { + template + void BayesNet::print(const string& s) const { cout << s << ":\n"; BOOST_REVERSE_FOREACH(sharedConditional conditional,conditionals_) conditional->print((boost::format("Node[%1%]") % conditional->key()).str()); } /* ************************************************************************* */ - template - bool BayesNet::equals(const BayesNet& cbn, double tol) const { + template + bool BayesNet::equals(const BayesNet& cbn, double tol) const { if(size() != cbn.size()) return false; - return equal(conditionals_.begin(),conditionals_.end(),cbn.conditionals_.begin(),equals_star(tol)); + return equal(conditionals_.begin(),conditionals_.end(),cbn.conditionals_.begin(),equals_star(tol)); } /* ************************************************************************* */ - template - void BayesNet::permuteWithInverse(const Permutation& inversePermutation) { + template + void BayesNet::permuteWithInverse(const Permutation& inversePermutation) { BOOST_FOREACH(sharedConditional conditional, conditionals_) { conditional->permuteWithInverse(inversePermutation); } } /* ************************************************************************* */ - template - bool BayesNet::permuteSeparatorWithInverse(const Permutation& inversePermutation) { + template + bool BayesNet::permuteSeparatorWithInverse(const Permutation& inversePermutation) { bool separatorChanged = false; BOOST_FOREACH(sharedConditional conditional, conditionals_) { if(conditional->permuteSeparatorWithInverse(inversePermutation)) @@ -71,22 +69,22 @@ namespace gtsam { } /* ************************************************************************* */ - template - void BayesNet::push_back(const BayesNet bn) { + template + void BayesNet::push_back(const BayesNet bn) { BOOST_FOREACH(sharedConditional conditional,bn.conditionals_) push_back(conditional); } /* ************************************************************************* */ - template - void BayesNet::push_front(const BayesNet bn) { + template + void BayesNet::push_front(const BayesNet bn) { BOOST_FOREACH(sharedConditional conditional,bn.conditionals_) push_front(conditional); } /* ************************************************************************* */ - template - list BayesNet::ordering() const { + template + list BayesNet::ordering() const { list ord; BOOST_FOREACH(sharedConditional conditional,conditionals_) ord.push_back(conditional->key()); @@ -94,8 +92,8 @@ namespace gtsam { } /* ************************************************************************* */ - template - void BayesNet::saveGraph(const std::string &s) const { + template + void BayesNet::saveGraph(const std::string &s) const { ofstream of(s.c_str()); of<< "digraph G{\n"; BOOST_FOREACH(const_sharedConditional conditional,conditionals_) { @@ -110,10 +108,10 @@ namespace gtsam { /* ************************************************************************* */ - template - typename BayesNet::sharedConditional - BayesNet::operator[](Index key) const { - const_iterator it = find_if(conditionals_.begin(), conditionals_.end(), boost::lambda::bind(&Conditional::key, *boost::lambda::_1) == key); + template + typename BayesNet::sharedConditional + BayesNet::operator[](Index key) const { + const_iterator it = find_if(conditionals_.begin(), conditionals_.end(), boost::lambda::bind(&CONDITIONAL::key, *boost::lambda::_1) == key); if (it == conditionals_.end()) throw(invalid_argument((boost::format( "BayesNet::operator['%1%']: not found") % key).str())); return *it; diff --git a/inference/BayesNet.h b/inference/BayesNet.h index d0bca3992..9a8cd7afc 100644 --- a/inference/BayesNet.h +++ b/inference/BayesNet.h @@ -19,16 +19,14 @@ #pragma once -#include -#include -#include -//#include -//#include - #include #include #include +#include +#include +#include + namespace gtsam { /** @@ -37,16 +35,16 @@ namespace gtsam { * corresponding to what is used for the "Conditional" template argument: * a SymbolicConditional, ConditionalProbabilityTable, or a GaussianConditional */ - template - class BayesNet: public Testable > { + template + class BayesNet: public Testable > { public: - typedef typename boost::shared_ptr > shared_ptr; + typedef typename boost::shared_ptr > shared_ptr; /** We store shared pointers to Conditional densities */ - typedef typename boost::shared_ptr sharedConditional; - typedef typename boost::shared_ptr const_sharedConditional; + typedef typename boost::shared_ptr sharedConditional; + typedef typename boost::shared_ptr const_sharedConditional; typedef typename std::list Conditionals; typedef typename Conditionals::const_iterator iterator; @@ -82,10 +80,10 @@ namespace gtsam { } // push_back an entire Bayes net */ - void push_back(const BayesNet bn); + void push_back(const BayesNet bn); // push_front an entire Bayes net */ - void push_front(const BayesNet bn); + void push_front(const BayesNet bn); /** * pop_front: remove node at the bottom, used in marginalization @@ -117,13 +115,13 @@ namespace gtsam { sharedConditional& front() { return conditionals_.front(); } /** return last node in ordering */ - boost::shared_ptr front() const { return conditionals_.front(); } + boost::shared_ptr front() const { return conditionals_.front(); } /** return last node in ordering */ sharedConditional& back() { return conditionals_.back(); } /** return last node in ordering */ - boost::shared_ptr back() const { return conditionals_.back(); } + boost::shared_ptr back() const { return conditionals_.back(); } /** return iterators. FD: breaks encapsulation? */ inline const_iterator const begin() const {return conditionals_.begin();} diff --git a/inference/BayesTree.h b/inference/BayesTree.h index c7fdec38b..1c1a08b8b 100644 --- a/inference/BayesTree.h +++ b/inference/BayesTree.h @@ -57,7 +57,7 @@ namespace gtsam { weak_ptr parent_; std::list children_; std::list separator_; /** separator keys */ - typename Conditional::FactorType::shared_ptr cachedFactor_; + typename Conditional::Factor::shared_ptr cachedFactor_; friend class BayesTree; @@ -87,7 +87,7 @@ namespace gtsam { const std::list& children() const { return children_; } /** Reference the cached factor */ - typename Conditional::FactorType::shared_ptr& cachedFactor() { return cachedFactor_; } + typename Conditional::Factor::shared_ptr& cachedFactor() { return cachedFactor_; } /** The size of subtree rooted at this clique, i.e., nr of Cliques */ size_t treeSize() const; diff --git a/inference/Conditional.h b/inference/Conditional.h index 707636767..a79d5c9d7 100644 --- a/inference/Conditional.h +++ b/inference/Conditional.h @@ -48,7 +48,7 @@ protected: public: /** convenience typename for a shared pointer to this class */ - typedef gtsam::Factor FactorType; + typedef gtsam::Factor Factor; typedef boost::shared_ptr shared_ptr; typedef Factor::iterator iterator; typedef Factor::const_iterator const_iterator; diff --git a/inference/inference-inl.h b/inference/inference-inl.h index d72cec464..d94c553cd 100644 --- a/inference/inference-inl.h +++ b/inference/inference-inl.h @@ -33,6 +33,7 @@ #include #include #include +#include using namespace std;