Fixed size() crash when BayesTree empty, added clear() function to BayesTree, added and removed #includes to fix link errors
parent
e767996b45
commit
19dc8bf4b1
|
@ -13,8 +13,8 @@ using namespace boost::assign;
|
|||
|
||||
#include "Ordering.h"
|
||||
#include "BayesNet.h"
|
||||
#include "FactorGraph-inl.h"
|
||||
#include "Conditional.h"
|
||||
//#include "FactorGraph-inl.h"
|
||||
//#include "Conditional.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ using namespace boost::assign;
|
|||
|
||||
#include "Conditional.h"
|
||||
#include "BayesTree.h"
|
||||
#include "Ordering.h"
|
||||
#include "inference-inl.h"
|
||||
|
||||
namespace gtsam {
|
||||
|
@ -386,6 +387,14 @@ namespace gtsam {
|
|||
return eliminate<Factor,Conditional>(fg,ordering);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<class Conditional>
|
||||
void BayesTree<Conditional>::clear() {
|
||||
// Remove all nodes and clear the root pointer
|
||||
nodes_.clear();
|
||||
root_.reset();
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<class Conditional>
|
||||
template<class Factor>
|
||||
|
|
|
@ -136,7 +136,10 @@ namespace gtsam {
|
|||
|
||||
/** number of cliques */
|
||||
inline size_t size() const {
|
||||
if(root_)
|
||||
return root_->treeSize();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** return root clique */
|
||||
|
@ -169,6 +172,11 @@ namespace gtsam {
|
|||
template<class Factor>
|
||||
BayesNet<Conditional> jointBayesNet(const Symbol& key1, const Symbol& key2) const;
|
||||
|
||||
/**
|
||||
* Remove all nodes
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Remove path from clique to root and return that path as factors
|
||||
* plus a list of orphaned subtree roots. Used in removeTop below.
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
using namespace boost::assign;
|
||||
|
||||
#include "Conditional.h"
|
||||
#include "BayesTree-inl.h"
|
||||
#include "ISAM.h"
|
||||
#include "BayesTree-inl.h"
|
||||
|
||||
namespace gtsam {
|
||||
|
||||
|
@ -22,7 +22,8 @@ namespace gtsam {
|
|||
|
||||
/** Create a Bayes Tree from a Bayes Net */
|
||||
template<class Conditional>
|
||||
ISAM<Conditional>::ISAM(const BayesNet<Conditional>& bayesNet) : BayesTree<Conditional>(bayesNet) {}
|
||||
ISAM<Conditional>::ISAM(const BayesNet<Conditional>& bayesNet) :
|
||||
BayesTree<Conditional>(bayesNet) {}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<class Conditional>
|
||||
|
@ -74,7 +75,5 @@ namespace gtsam {
|
|||
this->update_internal<Factor>(newFactors, orphans);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
||||
}
|
||||
/// namespace gtsam
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include "FactorGraph.h"
|
||||
#include "BayesNet.h"
|
||||
#include "BayesTree.h"
|
||||
#include "VectorConfig.h"
|
||||
#include "NonlinearFactorGraph.h"
|
||||
|
||||
namespace gtsam {
|
||||
|
||||
|
|
|
@ -111,6 +111,18 @@ TEST( BayesTree, constructor )
|
|||
CHECK(assert_equal(bayesTree,bayesTree2));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(BayesTree, clear)
|
||||
{
|
||||
SymbolicBayesTree bayesTree = createAsiaSymbolicBayesTree();
|
||||
bayesTree.clear();
|
||||
|
||||
SymbolicBayesTree expected;
|
||||
|
||||
// Check whether cleared BayesTree is equal to a new BayesTree
|
||||
CHECK(assert_equal(expected, bayesTree));
|
||||
}
|
||||
|
||||
/* ************************************************************************* *
|
||||
Bayes Tree for testing conversion to a forest of orphans needed for incremental.
|
||||
A,B
|
||||
|
|
Loading…
Reference in New Issue