[mlpack-svn] r16552 - in mlpack/trunk/src/mlpack/core/tree: binary_space_tree rectangle_tree

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon May 26 17:20:42 EDT 2014


Author: andrewmw94
Date: Mon May 26 17:20:41 2014
New Revision: 16552

Log:
more R tree stuff.  Still no build

Modified:
   mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
   mlpack/trunk/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
   mlpack/trunk/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp

Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp	Mon May 26 17:20:41 2014
@@ -441,7 +441,7 @@
   if (!IsLeaf())
     return 0.0;
 
-  // Otherwise return the distance from a corner of the bound to the centroid.
+  // Otherwise return the distance from the centroid to a corner of the bound.
   return 0.5 * bound.Diameter();
 }
 

Modified: mlpack/trunk/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp	Mon May 26 17:20:41 2014
@@ -28,7 +28,9 @@
  */   
 
 template<typename StatisticType = EmptyStatistic,
-	   typename MatType = arma::mat>
+	 typename MatType = arma::mat,
+	 typename SplitType = EmptySplit,
+	 typename DescentType = EmptyDescent>
 class RectangleTree
 {
  private:
@@ -88,6 +90,12 @@
   ~RectangleTree();
 
   /**
+   * Inserts a point into the tree. The point will be copied to the data matrix
+   * of the leaf node where it is finally inserted.
+   */
+  void InsertPoint(const arma::vec& point);
+
+  /**
    * Find a node in this tree by its begin and count (const).
    *
    * Every node is uniquely identified by these two numbers.

Modified: mlpack/trunk/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp	Mon May 26 17:20:41 2014
@@ -18,7 +18,8 @@
 
 template<typename StatisticType,
 	 typename MatType,
-	 typename SplitType>
+	 typename SplitType
+	 typename DescentType>
 RectangleTree<StatisticType, MatType, SplitType>::RectangleTree(
     MatType& data,
     const size_t leafSize):
@@ -29,6 +30,33 @@
 }
 
 /**
+ * Recurse through the tree and insert the point at the leaf node chosen
+ * by the heuristic.
+ */
+template<typename StatisticType,
+	 typename MatType,
+	 typename SplitType>
+RectangleTree<StatisticType, MatType, SplitType>::
+    InsertPoint(const arma::vec& point)
+{
+  if(numChildren == 0) {
+    data[points++] = point;
+    return;
+  }
+  double minDist = children[0].minDistance(point);
+  int bestIndex = 0;
+  for(int i = 1; i < numChildren; i++) {
+    double dist = children[i].minDistance(point);
+    if(dist < minDist) {
+      minDist = dist;
+      bestIndex = i
+    }
+  }
+  children[bestIndex].InsertPoint(point);
+}
+
+
+/**
  * Deletes this node, deallocating the memory for the children and calling
  * their destructors in turn.  This will invalidate any pointers or references
  * to any nodes which are children of this one.



More information about the mlpack-svn mailing list