[mlpack-git] master, mlpack-1.0.x: a few miscellanious small changes. Added to CMake. (3c6ee3d)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:48:29 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 3c6ee3d5ca32b0a43c956e78902e96815b767f36
Author: andrewmw94 <andrewmw94 at gmail.com>
Date:   Wed Jun 4 17:47:08 2014 +0000

    a few miscellanious small changes.  Added to CMake.


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

3c6ee3d5ca32b0a43c956e78902e96815b767f36
 src/mlpack/core/tree/CMakeLists.txt                |  7 +++++
 .../core/tree/rectangle_tree/rectangle_tree.hpp    | 34 ++++++++++++++--------
 .../tree/rectangle_tree/rectangle_tree_impl.hpp    |  2 ++
 3 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/src/mlpack/core/tree/CMakeLists.txt b/src/mlpack/core/tree/CMakeLists.txt
index 85c1d8d..8f60033 100644
--- a/src/mlpack/core/tree/CMakeLists.txt
+++ b/src/mlpack/core/tree/CMakeLists.txt
@@ -31,6 +31,13 @@ set(SOURCES
   mrkd_statistic.hpp
   mrkd_statistic_impl.hpp
   mrkd_statistic.cpp
+  rectangle_tree.hpp
+  rectangle_tree/rectangle_tree.hpp
+  rectangle_tree/rectangle_tree_impl.hpp
+  rectangle_tree/r_tree_split.hpp
+  rectangle_tree/r_tree_split_impl.hpp
+  rectangle_tree/r_tree_descent_heuristic.hpp
+  rectangle_tree/r_tree_descent_heuristic_impl.hpp
   statistic.hpp
   traversal_info.hpp
   tree_traits.hpp
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
index b143311..45a729a 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
@@ -40,8 +40,8 @@ class RectangleTree
   //! The minimum number of child nodes a non-leaf node can have.
   size_t minNumChildren;
   //! The number of child nodes actually in use (0 if this is a leaf node).
-  size_t numOfChildren;
-  //! The child nodes (Starting at 0 and ending at (numOfChildren-1) ).
+  size_t numChildren;
+  //! The child nodes (Starting at 0 and ending at (numChildren-1) ).
   std::vector<RectangleTree*> children;
   //! The parent node (NULL if this is the root of the tree).
   RectangleTree* parent;
@@ -150,11 +150,26 @@ class RectangleTree
   //! Return whether or not this node is a leaf (true if it has no children).
   bool IsLeaf() const;
 
-  //! Return the max leaf size.
+  //! Return the maximum leaf size.
   size_t MaxLeafSize() const { return maxLeafSize; }
-  //! Modify the max leaf size.
+  //! Modify the maximum leaf size.
   size_t& MaxLeafSize() { return maxLeafSize; }
 
+  //! Return the minimum leaf size.
+  size_t MinLeafSize() const { return minLeafSize; }
+  //! Modify the minimum leaf size.
+  size_t& MinLeafSize() { return minLeafSize; }
+
+  //! Return the maximum number of children (in a non-leaf node).
+  size_t MaxNumChildren() const { return maxNumChildren; }
+  //! Modify the maximum number of children (in a non-leaf node).
+  size_t& MaxNumChildren() { return maxNumChildren; }
+
+  //! Return the minimum number of children (in a non-leaf node).
+  size_t MinNumChildren() const { return minNumChildren; }
+  //! Modify the minimum number of children (in a non-leaf node).
+  size_t& MinNumChildren() { return minNumChildren; }
+
   //! Gets the parent of this node.
   RectangleTree* Parent() const { return parent; }
   //! Modify the parent of this node.
@@ -171,15 +186,10 @@ class RectangleTree
   //! Get the centroid of the node and store it in the given vector.
   void Centroid(arma::vec& centroid) { bound.Centroid(centroid); }
 
-  // TODO.  Think of a better name that makes the difference here obvious.
-
-  //! Return the number of children in this node.
-  size_t NumChildren() const;
-
   //! Return the number of child nodes.  (One level beneath this one only.)
-  size_t getNumOfChildren() const { return numOfChildren; }
+  size_t NumChildren() const { return numChildren; }
   //! Modify the number of child nodes.  Be careful.
-  size_t& getNumOfChildren() { return numOfChildren; }
+  size_t& NumChildren() { return numChildren; }
 
   //! Get the children of this node.
   const std::vector<RectangleTree*>& Children() const { return children; }
@@ -215,7 +225,7 @@ class RectangleTree
    */
   RectangleTree& Child(const size_t child) const;
 
-  //! Return the number of points in this node (0 if not a leaf).
+  //! Return the number of points in this node (returns 0 if this node is not a leaf).
   size_t NumPoints() const;
 
   /**
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 7059081..3737a3c 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
@@ -42,12 +42,14 @@ RectangleTree<StatisticType, MatType, SplitType, DescentType>::RectangleTree(
   this.parentDistance = 0.0;
   this.furthestDescendantDistance = 0.0;
   this.dataset = new MatType(maxLeafSize+1); // Add one to make splitting the node simpler
+  this.children = new std::vector<RectangleTree*>(maxNumChildren+1); // ibid.
   
   // For now, just insert the points in order.
   // This won't actually work for any meaningful size of data since the root changes.
   for(int i = 0; i < n_cols; i++) {
     insertPoint(data.col(i));
   }
+  
 }
 
 /**



More information about the mlpack-git mailing list