[mlpack-git] master, mlpack-1.0.x: more R tree stuff. Still no build (15c72dd)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:47:44 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 15c72dd15d63f7d42aba76a395fe49acc8a760c2
Author: andrewmw94 <andrewmw94 at gmail.com>
Date:   Mon May 26 21:20:41 2014 +0000

    more R tree stuff.  Still no build


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

15c72dd15d63f7d42aba76a395fe49acc8a760c2
 .../binary_space_tree/binary_space_tree_impl.hpp   |  2 +-
 .../core/tree/rectangle_tree/rectangle_tree.hpp    | 10 +++++++-
 .../tree/rectangle_tree/rectangle_tree_impl.hpp    | 30 +++++++++++++++++++++-
 3 files changed, 39 insertions(+), 3 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 9aa3883..506900a 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
@@ -441,7 +441,7 @@ inline double BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
   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();
 }
 
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
index 12c879d..3bf26a0 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
@@ -28,7 +28,9 @@ namespace tree /** Trees and tree-building procedures. */ {
  */   
 
 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 @@ class RectangleTree
   ~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.
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
index ed18b46..ddc009c 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
@@ -18,7 +18,8 @@ namespace tree {
 
 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 @@ RectangleTree<StatisticType, MatType, SplitType>::RectangleTree(
 }
 
 /**
+ * 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-git mailing list