[mlpack-git] master, mlpack-1.0.x: Use the bound's cached MinWidth() for MinimumBoundDistance(). (7a3a69f)

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


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

On branches: master,mlpack-1.0.x
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit 7a3a69fbdee467c6bcdbd2971208605333f67652
Author: Ryan Curtin <ryan at ratml.org>
Date:   Thu Jul 10 14:31:37 2014 +0000

    Use the bound's cached MinWidth() for MinimumBoundDistance().


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

7a3a69fbdee467c6bcdbd2971208605333f67652
 .../binary_space_tree/binary_space_tree_impl.hpp    | 21 +--------------------
 .../core/tree/rectangle_tree/rectangle_tree.hpp     |  2 +-
 2 files changed, 2 insertions(+), 21 deletions(-)

diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
index f8eb5cf..dc82eab 100644
--- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
@@ -238,7 +238,6 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
     splitDimension(other.splitDimension),
     parentDistance(other.parentDistance),
     furthestDescendantDistance(other.furthestDescendantDistance),
-    minimumBoundDistance(other.minimumBoundDistance),
     dataset(other.dataset)
 {
   // Create left and right children (if any).
@@ -471,7 +470,7 @@ template<typename BoundType,
 inline double BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
     MinimumBoundDistance() const
 {
-  return minimumBoundDistance;
+  return bound.MinWidth();
 }
 
 /**
@@ -572,15 +571,6 @@ void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::SplitNode(
   // Calculate the furthest descendant distance.
   furthestDescendantDistance = 0.5 * bound.Diameter();
 
-  // Find the minimum distance to any bound edge.
-  minimumBoundDistance = DBL_MAX;
-  for (size_t i = 0; i < bound.Dim(); ++i)
-  {
-    const double dist = std::max(bound[i].Hi() - bound[i].Lo(), 0.0);
-    if (dist < minimumBoundDistance)
-      minimumBoundDistance = dist;
-  }
-
   // Now, check if we need to split at all.
   if (count <= maxLeafSize)
     return; // We can't split this.
@@ -637,15 +627,6 @@ void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::SplitNode(
   // Calculate the furthest descendant distance.
   furthestDescendantDistance = 0.5 * bound.Diameter();
 
-  // Find the minimum distance to any bound edge.
-  minimumBoundDistance = DBL_MAX;
-  for (size_t i = 0; i < bound.Dim(); ++i)
-  {
-    const double dist = std::max(bound[i].Hi() - bound[i].Lo(), 0.0);
-    if (dist < minimumBoundDistance)
-      minimumBoundDistance = dist;
-  }
-
   // First, check if we need to split at all.
   if (count <= maxLeafSize)
     return; // We can't split this.
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
index 564454c..af00aab 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
@@ -268,7 +268,7 @@ class RectangleTree
   //! Return the minimum distance from the center to any edge of the bound.
   //! Currently, this returns 0, which doesn't break algorithms, but it isn't
   //! necessarily correct, either.
-  double MinimumBoundDistance() const { return 0.0; }
+  double MinimumBoundDistance() const { return bound.MinWidth(); }
 
   //! Return the distance from the center of this node to the center of the
   //! parent node.



More information about the mlpack-git mailing list