[mlpack-svn] r17122 - mlpack/tags/mlpack-1.0.10/src/mlpack/methods/neighbor_search

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Aug 26 12:21:20 EDT 2014


Author: rcurtin
Date: Tue Aug 26 12:21:20 2014
New Revision: 17122

Log:
Backport fixes for NeighborSearch from trunk.


Modified:
   mlpack/tags/mlpack-1.0.10/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp

Modified: mlpack/tags/mlpack-1.0.10/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
==============================================================================
--- mlpack/tags/mlpack-1.0.10/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp	(original)
+++ mlpack/tags/mlpack-1.0.10/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp	Tue Aug 26 12:21:20 2014
@@ -355,17 +355,20 @@
 
   // 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() +
-        2 * (queryNode.FurthestDescendantDistance() -
-             queryNode.Child(i).FurthestDescendantDistance());
+    const double adjustment = std::max(0.0,
+        queryNode.FurthestDescendantDistance() -
+        queryNode.Child(i).FurthestDescendantDistance());
+    const double adjustedSecondBound = SortPolicy::CombineWorst(
+        queryNode.Child(i).Stat().SecondBound(), 2 * adjustment);
 
     if (SortPolicy::IsBetter(worstDistance, firstBound))
       worstDistance = firstBound;



More information about the mlpack-svn mailing list