[mlpack] 21/324: more R tree stuff. Still no build

Barak A. Pearlmutter barak+git at cs.nuim.ie
Sun Aug 17 08:21:52 UTC 2014


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch svn-trunk
in repository mlpack.

commit bf8e28378f5bb9ac0fa9167c020a3cc8d2089402
Author: andrewmw94 <andrewmw94 at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Mon May 26 21:20:41 2014 +0000

    more R tree stuff.  Still no build
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16552 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 .../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.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list