[mlpack-git] master: Correctly handle SortPolicy abstraction. (561ba6d)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:59:49 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit 561ba6df128d23d61733ef4355405c7e380e7df1
Author: Ryan Curtin <ryan at ratml.org>
Date:   Tue Aug 26 03:40:02 2014 +0000

    Correctly handle SortPolicy abstraction.


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

561ba6df128d23d61733ef4355405c7e380e7df1
 .../methods/neighbor_search/neighbor_search_rules_impl.hpp     | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
index bdafbb1..9a009d9 100644
--- a/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
+++ b/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
@@ -355,17 +355,19 @@ inline double NeighborSearchRules<SortPolicy, MetricType, TreeType>::
 
   // Add triangle inequality adjustment to best distance.  It is possible this
   // could be tighter for some certain types of trees.
-  bestDistance += queryNode.FurthestPointDistance() +
-      queryNode.FurthestDescendantDistance();
+  bestDistance = SortPolicy::CombineWorst(bestDistance,
+      queryNode.FurthestPointDistance() +
+      queryNode.FurthestDescendantDistance());
 
   // Loop over children of the node, and use their cached information to
   // assemble bounds.
   for (size_t i = 0; i < queryNode.NumChildren(); ++i)
   {
     const double firstBound = queryNode.Child(i).Stat().FirstBound();
-    const double adjustedSecondBound = queryNode.Child(i).Stat().SecondBound() +
+    const double adjustedSecondBound = SortPolicy::CombineWorst(
+        queryNode.Child(i).Stat().SecondBound(),
         2 * (queryNode.FurthestDescendantDistance() -
-             queryNode.Child(i).FurthestDescendantDistance());
+             queryNode.Child(i).FurthestDescendantDistance()));
 
     if (SortPolicy::IsBetter(worstDistance, firstBound))
       worstDistance = firstBound;



More information about the mlpack-git mailing list