From d3cae3481ba55eff3cae74229b90ef7040e936fe Mon Sep 17 00:00:00 2001 From: MarcosPividori Date: Fri, 3 Jun 2016 09:43:33 -0300 Subject: [PATCH] Properly resetting auxBound. Start using a Reset() method, to avoid futures errors like this. --- .../methods/neighbor_search/neighbor_search_impl.hpp | 4 +--- .../methods/neighbor_search/neighbor_search_stat.hpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp index e092766ebbb..d86f5146e1a 100644 --- a/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp +++ b/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp @@ -638,9 +638,7 @@ Search(const size_t k, nodes.pop(); // Reset bounds of this node. - node->Stat().FirstBound() = SortPolicy::WorstDistance(); - node->Stat().SecondBound() = SortPolicy::WorstDistance(); - node->Stat().LastDistance() = 0.0; + node->Stat().Reset(); // Then add the children. for (size_t i = 0; i < node->NumChildren(); ++i) diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_stat.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_stat.hpp index dfcc5ad743b..433ea6486a7 100644 --- a/src/mlpack/methods/neighbor_search/neighbor_search_stat.hpp +++ b/src/mlpack/methods/neighbor_search/neighbor_search_stat.hpp @@ -57,6 +57,17 @@ class NeighborSearchStat auxBound(SortPolicy::WorstDistance()), lastDistance(0.0) { } + /** + * Reset statistic parameters to initial values. + */ + void Reset() + { + firstBound = SortPolicy::WorstDistance(); + secondBound = SortPolicy::WorstDistance(); + auxBound = SortPolicy::WorstDistance(); + lastDistance = 0.0; + } + //! Get the first bound. double FirstBound() const { return firstBound; } //! Modify the first bound.