[mlpack-svn] r13380 - in mlpack/trunk/src/mlpack/core/tree: . cover_tree

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Aug 9 14:33:53 EDT 2012


Author: rcurtin
Date: 2012-08-09 14:33:51 -0400 (Thu, 09 Aug 2012)
New Revision: 13380

Added:
   mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_map_entry.hpp
Modified:
   mlpack/trunk/src/mlpack/core/tree/CMakeLists.txt
   mlpack/trunk/src/mlpack/core/tree/cover_tree/single_tree_traverser_impl.hpp
Log:
Split CoverTreeMapEntry into its own file since it will also be used by the dual tree traverser.


Modified: mlpack/trunk/src/mlpack/core/tree/CMakeLists.txt
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/CMakeLists.txt	2012-08-09 09:02:13 UTC (rev 13379)
+++ mlpack/trunk/src/mlpack/core/tree/CMakeLists.txt	2012-08-09 18:33:51 UTC (rev 13380)
@@ -14,6 +14,7 @@
   bounds.hpp
   cover_tree/cover_tree.hpp
   cover_tree/cover_tree_impl.hpp
+  cover_tree/cover_tree_map_entry.hpp
   cover_tree/first_point_is_root.hpp
   cover_tree/single_tree_traverser.hpp
   cover_tree/single_tree_traverser_impl.hpp

Copied: mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_map_entry.hpp (from rev 13379, mlpack/trunk/src/mlpack/core/tree/cover_tree/single_tree_traverser_impl.hpp)
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_map_entry.hpp	                        (rev 0)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_map_entry.hpp	2012-08-09 18:33:51 UTC (rev 13380)
@@ -0,0 +1,37 @@
+/**
+ * @file cover_tree_map_entry.hpp
+ * @author Ryan Curtin
+ *
+ * Definition of a simple struct which is used in cover tree traversal to
+ * represent the data associated with a single cover tree node.
+ */
+#ifndef __MLPACK_CORE_TREE_COVER_TREE_COVER_TREE_MAP_ENTRY_HPP
+#define __MLPACK_CORE_TREE_COVER_TREE_COVER_TREE_MAP_ENTRY_HPP
+
+namespace mlpack {
+namespace tree {
+
+//! This is the structure the cover tree map will use for traversal.
+template<typename MetricType, typename RootPointPolicy, typename StatisticType>
+struct CoverTreeMapEntry
+{
+  //! The node this entry refers to.
+  CoverTree<MetricType, RootPointPolicy, StatisticType>* node;
+  //! The score of the node.
+  double score;
+  //! The index of the parent node.
+  size_t parent;
+  //! The base case evaluation.
+  double baseCase;
+
+  //! Comparison operator.
+  bool operator<(const CoverTreeMapEntry& other) const
+  {
+    return (score < other.score);
+  }
+};
+
+}; // namespace tree
+}; // namespace mlpack
+
+#endif

Modified: mlpack/trunk/src/mlpack/core/tree/cover_tree/single_tree_traverser_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/cover_tree/single_tree_traverser_impl.hpp	2012-08-09 09:02:13 UTC (rev 13379)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/single_tree_traverser_impl.hpp	2012-08-09 18:33:51 UTC (rev 13380)
@@ -11,34 +11,13 @@
 // In case it hasn't been included yet.
 #include "single_tree_traverser.hpp"
 
+#include "cover_tree_map_entry.hpp"
 #include <queue>
 
 namespace mlpack {
 namespace tree {
 
-//! This is the structure the priority queue will use for traversal.
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
-struct CoverTreeQueueEntry
-{
-  //! The node this entry refers to.
-  CoverTree<MetricType, RootPointPolicy, StatisticType>* node;
-  //! The score of the node.
-  double score;
-  //! The index of the parent node.
-  size_t parent;
-  //! The base case evaluation (-1.0 if it has not been performed).
-  double baseCase;
-
-  //! Comparison operator.
-  bool operator<(const CoverTreeQueueEntry& other) const
-  {
-    return (score < other.score);
-  }
-};
-
-
-
-template<typename MetricType, typename RootPointPolicy, typename StatisticType>
 template<typename RuleType>
 CoverTree<MetricType, RootPointPolicy, StatisticType>::
 SingleTreeTraverser<RuleType>::SingleTreeTraverser(RuleType& rule) :
@@ -55,7 +34,7 @@
 {
   // This is a non-recursive implementation (which should be faster than a
   // recursive implementation).
-  typedef CoverTreeQueueEntry<MetricType, RootPointPolicy, StatisticType>
+  typedef CoverTreeMapEntry<MetricType, RootPointPolicy, StatisticType>
       QueueType;
 
   // We will use this map as a priority queue.  Each key represents the scale,
@@ -69,7 +48,7 @@
   // Manually add the children of the first node.  These cannot be pruned
   // anyway.
   double rootBaseCase = rule.BaseCase(queryIndex, referenceNode.Point());
-    
+
   // Create the score for the children.
   double rootChildScore = rule.Score(queryIndex, referenceNode, rootBaseCase);
 




More information about the mlpack-svn mailing list