/** * @file BayesNet-inl.h * @brief Bayes chain template definitions * @author Frank Dellaert */ #include #include #include #include // for += using namespace boost::assign; #include "Ordering.h" #include "BayesNet.h" using namespace std; namespace gtsam { /* ************************************************************************* */ template void BayesNet::print(const string& s) const { cout << s << ":\n"; std::string key; BOOST_FOREACH(conditional_ptr conditional,conditionals_) conditional->print("Node[" + conditional->key() + "]"); } /* ************************************************************************* */ template bool BayesNet::equals(const BayesNet& cbn, double tol) const { if(indices_ != cbn.indices_) return false; if(size() != cbn.size()) return false; return equal(conditionals_.begin(),conditionals_.begin(),conditionals_.begin(),equals_star); } /* ************************************************************************* */ template void BayesNet::push_back (const boost::shared_ptr& conditional) { indices_.insert(make_pair(conditional->key(),conditionals_.size())); conditionals_.push_back(conditional); } /* ************************************************************************* * template void BayesNet::erase(const string& key) { list::iterator it; for (it=keys_.begin(); it != keys_.end(); ++it){ if( strcmp(key.c_str(), (*it).c_str()) == 0 ) break; } keys_.erase(it); conditionals_.erase(key); } /* ************************************************************************* */ template Ordering BayesNet::ordering() const { Ordering ord; BOOST_FOREACH(conditional_ptr conditional,conditionals_) ord.push_back(conditional->key()); return ord; } /* ************************************************************************* */ } // namespace gtsam