[mlpack] 19/324: more code for the RectangleTree. Still not built yet.

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 efbd62b80ed7dc2aff24c12b1f675b18f3bcd4a9
Author: andrewmw94 <andrewmw94 at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Mon May 26 11:35:15 2014 +0000

    more code for the RectangleTree.  Still not built yet.
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16548 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 .../core/tree/rectangle_tree/rectangle_tree.hpp    |  14 +--
 .../tree/rectangle_tree/rectangle_tree_impl.hpp    | 125 ++++++++++++++++++++-
 2 files changed, 130 insertions(+), 9 deletions(-)

diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
index fed4534..12c879d 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
@@ -271,7 +271,7 @@ class RectangleTree
   size_t& Begin() { return begin; }
 
   /**
-   * Gets the index one beyond the last index in the subset.
+   * Gets the index one beyond the last index in the subset.  CURRENTLY MEANINGLESS!
    */
   size_t End() const;
 
@@ -305,18 +305,18 @@ class RectangleTree
   }
 
   /**
-   * Splits the current node, assigning its left and right children recursively.
+   * Splits the current node, recursing up the tree.
    *
-   * @param data Dataset which we are using.
+   * @param tree The RectangleTree object (node) to split.
    */
-  void SplitNode(MatType& data);
+  void SplitNode(RectangleTree& tree);
 
   /**
-   * Splits the current node, assigning its left and right children recursively.
-   * Also returns a list of the changed indices.
+   * Splits the current node, recursing up the tree.
+   * CURRENTLY IT DOES NOT Also returns a list of the changed indices.
    *
    * @param data Dataset which we are using.
-   * @param oldFromNew Vector holding permuted indices.
+   * @param oldFromNew Vector holding permuted indices NOT IMPLEMENTED.
    */
   void SplitNode(MatType& data, std::vector<size_t>& oldFromNew);
 
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 dd063a4..df48dcb 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
@@ -6,17 +6,138 @@
 #ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_IMPL_HPP
 #define __MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_IMPL_HPP
 
-// In case it wasn't included already for sem reason.
+// In case it wasn't included already for some reason.
 #include "rectangle_tree.hpp"
 
+#include <mlpack/core/util/cli.hpp>
+#include <mlpack/core/util/log.hpp>
+#include <mlpack/core/util/string_util.hpp>
+
 namespace mlpack {
 namespace tree {
 
 template<typename StatisticType,
 	 typename MatType,
 	 typename SplitType>
-RectangleTree<StatisticType, MatType, SplitType>::RectangleTree()
+RectangleTree<StatisticType, MatType, SplitType>::RectangleTree(
+    MatType& data,
+    const size_t leafSize):
+
+{
+  //Do the actual stuff here
+
+}
+
+/**
+ * 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.
+ */
+template<typename StatisticType,
+	   typename MatType,
+	   typename SplitType>
+RectangleTree<BoundType, StatisticType, MatType, SplitType>::
+  ~RectangleTree()
+{
+  for(int i = 0; i < numOfChildren; i++) {
+    delete children[i];
+  }
+}
 
+template<typename StatisticType,
+	 typename MatType,
+	 typename SplitType>
+size_t RectangleTree<StatisticType, MatType, SplitType>::
+    TreeSize() const
+{
+  int n = 0;
+  for(int i = 0; i < numOfChildren; i++) {
+    n += children[i].TreeSize();
+  }
+  return n + 1; // we add one for this node
+}
+
+
+
+template<typename StatisticType,
+	 typename MatType,
+	 typename SplitType>
+size_t RectangleTree<StatisticType, MatType, SplitType>::
+    TreeDepth() const
+{
+  // Recursively count the depth of each subtree.  The plus one is
+  // because we have to count this node, too.
+  int maxSubDepth = 0;
+  for(int i = 0; i < numOfChildren; i++) {
+    int d = children[i].depth();
+    if(d > maxSubDepth)
+      maxSubDepth = d;
+  }
+  return maxSubDepth + 1;
+}
+
+template<typename StatisticType,
+         	typename MatType,
+         	typename SplitType>
+inline bool BinarySpaceTree<StatisticType, MatType, SplitType>::
+    IsLeaf() const
+{
+  return numOfChildren == 0;
+}
+
+/**
+ * Return the last point in the tree.  SINCE THE TREE STORES DATA SEPARATELY IN EACH LEAF
+ * THIS IS CURRENTLY MEANINGLESS.
+ */
+template<typename StatisticType,
+	 typename MatType,
+	 typename SplitType>
+inline size_t RectangleTree<StatisticType, MatType, SplitType>::End() const
+{
+  if(numOfChildren)
+    return begin + count;
+  return children[numOfChildren-1].End();
+}
+
+  //have functions for returning the list of modified indices if we end up doing it that way.
+
+/**
+ * Split the tree.  This moves up the tree recursively.
+ */
+template<typename StatisticType,
+	 typename MatType,
+	 typename SplitType>
+void RectangleTree<StatisticType, MatType, SplitType>::SplitNode(
+    RetangleTree& tree)
+{
+  
+}
+
+
+/**
+ * Returns a string representation of this object.
+ */
+  template<typename StatisticType,
+	   typename MatType,
+	   typename SplitType>
+std::string BinarySpaceTree<StatisticType, MatType, SplitType>::ToString() const
+{
+  std::ostringstream convert;
+  convert << "RectangleTree [" << this << "]" << std::endl;
+  convert << "  First point: " << begin << std::endl;
+  convert << "  Number of descendants: " << count << std::endl;
+  convert << "  Bound: " << std::endl;
+  convert << mlpack::util::Indent(bound.ToString(), 2);
+  convert << "  Statistic: " << std::endl;
+  convert << mlpack::util::Indent(stat.ToString(), 2);
+  convert << "  Leaf size: " << leafSize << std::endl;
+  convert << "  Split dimension: " << splitDimension << std::endl;
+
+  // How many levels should we print?  This will print the top two tree levels.
+  for(
+}
 
 }; //namespace tree
 }; //namespace mlpack
+
+#endif

-- 
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