From 2ac1473a84f1785cefe1a12008cd370548e6cd5c Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Mon, 9 Apr 2012 03:02:11 +0000 Subject: [PATCH] Fixed iSAM2 deep copy of empty tree --- gtsam/inference/BayesTree-inl.h | 7 +++++++ gtsam/inference/BayesTree.h | 4 +--- tests/testGaussianISAM2.cpp | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gtsam/inference/BayesTree-inl.h b/gtsam/inference/BayesTree-inl.h index 6881e9a69..95b070739 100644 --- a/gtsam/inference/BayesTree-inl.h +++ b/gtsam/inference/BayesTree-inl.h @@ -582,6 +582,13 @@ namespace gtsam { } } + /* ************************************************************************* */ + template + void BayesTree::cloneTo(This& newTree) const { + if(root()) + cloneTo(newTree, root(), sharedClique()); + } + /* ************************************************************************* */ template void BayesTree::cloneTo( diff --git a/gtsam/inference/BayesTree.h b/gtsam/inference/BayesTree.h index 3df697a48..aba7181ff 100644 --- a/gtsam/inference/BayesTree.h +++ b/gtsam/inference/BayesTree.h @@ -283,9 +283,7 @@ namespace gtsam { private: /** deep copy to another tree */ - void cloneTo(This& newTree) const { - cloneTo(newTree, root(), sharedClique()); - } + void cloneTo(This& newTree) const; /** deep copy to another tree */ void cloneTo(This& newTree, const sharedClique& subtree, const sharedClique& parent) const; diff --git a/tests/testGaussianISAM2.cpp b/tests/testGaussianISAM2.cpp index 5ff24070c..9b1bd546f 100644 --- a/tests/testGaussianISAM2.cpp +++ b/tests/testGaussianISAM2.cpp @@ -898,6 +898,11 @@ TEST(ISAM2, clone) { CHECK(assert_equal(createSlamlikeISAM2(), clone1)); CHECK(assert_equal(clone1, temp)); + + // Check clone empty + ISAM2 isam; + clone1 = isam; + CHECK(assert_equal(ISAM2(), clone1)); } /* ************************************************************************* */