From f39bad0d137d56603c050d53b09e15743cfaaab6 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Fri, 3 Aug 2012 19:05:48 +0000 Subject: [PATCH] When erasing cached shortcut conditionals in the Bayes Tree, only erase the chains of shortcuts that exist instead of the whole tree. --- gtsam/inference/BayesTreeCliqueBase-inl.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gtsam/inference/BayesTreeCliqueBase-inl.h b/gtsam/inference/BayesTreeCliqueBase-inl.h index f96566536..344f845ac 100644 --- a/gtsam/inference/BayesTreeCliqueBase-inl.h +++ b/gtsam/inference/BayesTreeCliqueBase-inl.h @@ -268,12 +268,19 @@ namespace gtsam { /* ************************************************************************* */ template void BayesTreeCliqueBase::deleteCachedShorcuts() { - //Delete CachedShortcut for this clique - this->resetCachedShortcut(); - // Recursive call over all child cliques - BOOST_FOREACH(derived_ptr& child, children_) { - child->deleteCachedShorcuts(); - } + + // When a shortcut is requested, all of the shortcuts between it and the + // root are also generated. So, if this clique's cached shortcut is set, + // recursively call over all child cliques. Otherwise, it is unnecessary. + if(cachedShortcut_) { + BOOST_FOREACH(derived_ptr& child, children_) { + child->deleteCachedShorcuts(); + } + + //Delete CachedShortcut for this clique + this->resetCachedShortcut(); + } + } }