[mlpack-git] master: Properly resetting auxBound. Start using a Reset() method, to avoid futures errors like this. (d3cae34)

gitdub at mlpack.org gitdub at mlpack.org
Fri Jun 3 10:57:35 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/5b8fdce471328f722fcd8c0f22a6d995ce22c98b...719f47feca9f55d54b8ed7d6ba7335d8e5f90e90

>---------------------------------------------------------------

commit d3cae3481ba55eff3cae74229b90ef7040e936fe
Author: MarcosPividori <marcos.pividori at gmail.com>
Date:   Fri Jun 3 09:43:33 2016 -0300

    Properly resetting auxBound. Start using a Reset() method, to avoid futures errors like this.


>---------------------------------------------------------------

d3cae3481ba55eff3cae74229b90ef7040e936fe
 src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp |  4 +---
 src/mlpack/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 e092766..d86f514 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 dfcc5ad..433ea64 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.




More information about the mlpack-git mailing list