[mlpack] 48/324: comment out compilation. Some small changes to support R tree in all_knn

Barak A. Pearlmutter barak+git at cs.nuim.ie
Sun Aug 17 08:21:54 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 d7f04e786a075897e98861d99414357a6e2f6b07
Author: andrewmw94 <andrewmw94 at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Mon Jun 9 15:24:51 2014 +0000

    comment out compilation.  Some small changes to support R tree in all_knn
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16677 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 src/mlpack/core/tree/rectangle_tree.hpp                  |  2 ++
 .../tree/rectangle_tree/r_tree_descent_heuristic.hpp     |  6 +++---
 .../rectangle_tree/r_tree_descent_heuristic_impl.hpp     |  4 ++--
 src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp   |  4 +++-
 .../core/tree/rectangle_tree/rectangle_tree_impl.hpp     | 12 ++++++++----
 .../tree/rectangle_tree/rectangle_tree_traverser.hpp     | 16 ++++++++--------
 src/mlpack/methods/neighbor_search/allknn_main.cpp       | 13 ++++++++++++-
 src/mlpack/methods/neighbor_search/neighbor_search.hpp   |  1 +
 8 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/src/mlpack/core/tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree.hpp
index 7330adc..07907bf 100644
--- a/src/mlpack/core/tree/rectangle_tree.hpp
+++ b/src/mlpack/core/tree/rectangle_tree.hpp
@@ -14,6 +14,8 @@
 #include "bounds.hpp"
 #include "rectangle_tree/rectangle_tree.hpp"
 #include "rectangle_tree/rectangle_tree_traverser.hpp"
+#include "rectangle_tree/r_tree_split.hpp"
+#include "rectangle_tree/r_tree_descent_heuristic.hpp"
 #include "rectangle_tree/traits.hpp"
 
 #endif
diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic.hpp
index f023a02..c80608c 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic.hpp
@@ -5,8 +5,8 @@
  * Definition of RTreeDescentHeuristic, a class that chooses the best child of a node in
  * an R tree when inserting a new point.
  */
-#ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC.HPP
-#define __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC.HPP
+#ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_HPP
+#define __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_HPP
 
 #include <mlpack/core.hpp>
 
@@ -39,4 +39,4 @@ class RTreeDescentHueristic
 // Include implementation.
 #include "r_tree_descent_heuristic_impl.hpp"
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp
index 9039a78..67fc837 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp
@@ -5,8 +5,8 @@
  * Definition of RTreeDescentHeuristic, a class that chooses the best child of a node in
  * an R tree when inserting a new point.
  */
-#ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_IMPL.HPP
-#define __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_IMPL.HPP
+#ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_IMPL_HPP
+#define __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_IMPL_HPP
 
 #include "r_tree_descent_heuristic.hpp"
 
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
index 45a729a..641a315 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
@@ -26,6 +26,8 @@ namespace tree /** Trees and tree-building procedures. */ {
  * @tparam StatisticType Extra data contained in the node.  See statistic.hpp
  *     for the necessary skeleton interface.
  * @tparam MatType The dataset class.
+ * @tparam SplitType The type of split to use when inserting points.
+ * @tparam DescentType The heuristic to use when descending the tree to insert points.
  */   
 
 template<typename StatisticType = EmptyStatistic,
@@ -72,7 +74,7 @@ class RectangleTree
   //! So other classes can use TreeType::Mat.
   typedef MatType Mat;
 
-  //! A traverser for rectangle type trees; see
+  //! A traverser for rectangle type trees.  See
   //! rectangle_tree_traverser.hpp for implementation.
   template<typename RuleType>
   class RectangleTreeTraverser;
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 3737a3c..87c042b 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
@@ -26,7 +26,8 @@ RectangleTree<StatisticType, MatType, SplitType, DescentType>::RectangleTree(
     const size_t maxLeafSize,
     const size_t minLeafSize,
     const size_t maxNumChildren,
-    const size_t minNumChildren):
+    const size_t minNumChildren,
+    const size_t firstDataIndex = 0):
 
 {
   this.maxNumChildren = maxNumChildren;
@@ -45,9 +46,12 @@ RectangleTree<StatisticType, MatType, SplitType, DescentType>::RectangleTree(
   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));
+  RectangleTree* root = this;
+  for(int i = firstDataIndex; i < n_cols; i++) {
+    root.insertPoint(data.col(i));
+    if(root.Parent() != NULL) {
+      root = root.Parent(); // OK since the level increases by at most one per iteration.
+    }
   }
   
 }
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_traverser.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_traverser.hpp
index 1531832..17571c4 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_traverser.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_traverser.hpp
@@ -2,9 +2,9 @@
   * @file rectangle_tree_traverser.hpp
   * @author Andrew Wells
   *
-  * A class for traversing rectangle type trees with a given set of rules
-  * which indicate the branches to prune and the order in which to recurse.
-  * This is a depth-first traverser.
+  * A nested class of Rectangle Tree for traversing rectangle type trees
+  * with a given set of rules which indicate the branches to prune and the
+  * order in which to recurse.  This is a depth-first traverser.
   */
 #ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_TRAVERSER_HPP
 #define __MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_TRAVERSER_HPP
@@ -17,9 +17,9 @@ namespace mlpack {
 namespace tree {
 
 template<typename StatisticType,
-    typename MatType,
-    typename SplitType
-    typename DescentType>
+         typename MatType,
+         typename SplitType,
+         typename DescentType>
 template<typename RuleType>
 class RectangleTree<StatisticType, MatType, SplitType, DescentType>::
     RectangleTreeTraverser
@@ -50,7 +50,7 @@ class RectangleTree<StatisticType, MatType, SplitType, DescentType>::
 
   //! The number of nodes which have been prenud during traversal.
   size_t numPrunes;
-}
+};
 
 
 }; // namespace tree
@@ -59,4 +59,4 @@ class RectangleTree<StatisticType, MatType, SplitType, DescentType>::
 // Include implementation.
 #include "rectangle_tree_traverser_impl.hpp"
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/mlpack/methods/neighbor_search/allknn_main.cpp b/src/mlpack/methods/neighbor_search/allknn_main.cpp
index ae61205..1157041 100644
--- a/src/mlpack/methods/neighbor_search/allknn_main.cpp
+++ b/src/mlpack/methods/neighbor_search/allknn_main.cpp
@@ -266,8 +266,19 @@ int main(int argc, char *argv[])
 
       delete allknn;
     } else { // R tree.
+      // Make sure to notify the user that they are using an r tree.
+      Log::Info << "Using r tree for nearest-neighbor calculation." << endl;
       
-      
+      // Build the reference tree.
+      Log::Info << "Building reference tree..." << endl;
+      Timer::Start("tree_building");
+//       RectangleTree<NeighborSearchStat<NearestNeighborSort>,
+//                                  arma::mat,
+//                                  tree::RTreeSplit,
+//                                  tree::RTreeDescentHeuristic>
+//       refTree(referenceData, leafSize);
+      Timer::Stop("tree_building");
+        
     }
   }
   else // Cover trees.
diff --git a/src/mlpack/methods/neighbor_search/neighbor_search.hpp b/src/mlpack/methods/neighbor_search/neighbor_search.hpp
index 71ad1fc..a931957 100644
--- a/src/mlpack/methods/neighbor_search/neighbor_search.hpp
+++ b/src/mlpack/methods/neighbor_search/neighbor_search.hpp
@@ -13,6 +13,7 @@
 #include <string>
 
 #include <mlpack/core/tree/binary_space_tree.hpp>
+//#include <mlpack/core/tree/rectangle_tree.hpp>
 
 #include <mlpack/core/metrics/lmetric.hpp>
 #include "neighbor_search_stat.hpp"

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