[mlpack-git] master, mlpack-1.0.x: Split RAQueryStat into its own class. (8ffc85a)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:51:25 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 8ffc85adc235153dda77df6da3fe6dcff6948d35
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Jul 7 11:46:05 2014 +0000

    Split RAQueryStat into its own class.


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

8ffc85adc235153dda77df6da3fe6dcff6948d35
 src/mlpack/methods/rann/CMakeLists.txt    |  8 ++--
 src/mlpack/methods/rann/ra_query_stat.hpp | 67 +++++++++++++++++++++++++++++++
 src/mlpack/methods/rann/ra_search.hpp     | 51 +----------------------
 3 files changed, 73 insertions(+), 53 deletions(-)

diff --git a/src/mlpack/methods/rann/CMakeLists.txt b/src/mlpack/methods/rann/CMakeLists.txt
index c5af352..b848cd2 100644
--- a/src/mlpack/methods/rann/CMakeLists.txt
+++ b/src/mlpack/methods/rann/CMakeLists.txt
@@ -2,16 +2,18 @@
 # Anything not in this list will not be compiled into the output library
 # Do not include test programs here
 set(SOURCES
-
   # rank-approximate search files
   ra_search.hpp
   ra_search_impl.hpp
 
-  # The rank-approximate search rules
+  # rank-approximate search rules
   ra_search_rules.hpp
   ra_search_rules_impl.hpp
 
-  # The typedefs
+  # query statistic
+  ra_query_stat.hpp
+
+  # typedefs
   ra_typedef.hpp
 )
 
diff --git a/src/mlpack/methods/rann/ra_query_stat.hpp b/src/mlpack/methods/rann/ra_query_stat.hpp
new file mode 100644
index 0000000..47ad4dc
--- /dev/null
+++ b/src/mlpack/methods/rann/ra_query_stat.hpp
@@ -0,0 +1,67 @@
+/**
+ * @file ra_query_stat.hpp
+ * @author Parikshit Ram
+ *
+ * Defines the RAQueryStat class, which is the statistic used for
+ * rank-approximate nearest neighbor search (RASearch).
+ */
+#ifndef __MLPACK_METHODS_RANN_RA_QUERY_STAT_HPP
+#define __MLPACK_METHODS_RANN_RA_QUERY_STAT_HPP
+
+#include <mlpack/core.hpp>
+
+#include <mlpack/core/tree/binary_space_tree.hpp>
+
+#include <mlpack/core/metrics/lmetric.hpp>
+#include <mlpack/methods/neighbor_search/sort_policies/nearest_neighbor_sort.hpp>
+
+namespace mlpack {
+namespace neighbor {
+
+/**
+ * Extra data for each node in the tree.  For neighbor searches, each node only
+ * needs to store a bound on neighbor distances.
+ *
+ * Every query is required to make a minimum number of samples to guarantee the
+ * desired approximation error. The 'numSamplesMade' keeps track of the minimum
+ * number of samples made by all queries in the node in question.
+ */
+template<typename SortPolicy>
+class RAQueryStat
+{
+ public:
+  /**
+   * Initialize the statistic with the worst possible distance according to our
+   * sorting policy.
+   */
+  RAQueryStat() : bound(SortPolicy::WorstDistance()), numSamplesMade(0) { }
+
+  /**
+   * Initialization for a node.
+   */
+  template<typename TreeType>
+  RAQueryStat(const TreeType& /* node */) :
+    bound(SortPolicy::WorstDistance()),
+    numSamplesMade(0)
+  { }
+
+  //! Get the bound.
+  double Bound() const { return bound; }
+  //! Modify the bound.
+  double& Bound() { return bound; }
+
+  //! Get the number of samples made.
+  size_t NumSamplesMade() const { return numSamplesMade; }
+  //! Modify the number of samples made.
+  size_t& NumSamplesMade() { return numSamplesMade; }
+
+ private:
+  //! The bound on the node's neighbor distances.
+  double bound;
+
+  //! The minimum number of samples made by any query in this node.
+  size_t numSamplesMade;
+
+};
+
+#endif
diff --git a/src/mlpack/methods/rann/ra_search.hpp b/src/mlpack/methods/rann/ra_search.hpp
index 4c50e06..c25e468 100644
--- a/src/mlpack/methods/rann/ra_search.hpp
+++ b/src/mlpack/methods/rann/ra_search.hpp
@@ -25,56 +25,7 @@
 #include <mlpack/core/metrics/lmetric.hpp>
 #include <mlpack/methods/neighbor_search/sort_policies/nearest_neighbor_sort.hpp>
 
-namespace mlpack {
-namespace neighbor /** Neighbor-search routines.  These include
-                    * all-nearest-neighbors and all-furthest-neighbors
-                    * searches. */ {
-
-/**
- * Extra data for each node in the tree.  For neighbor searches, each node only
- * needs to store a bound on neighbor distances.
- *
- * Every query is required to make a minimum number of samples to guarantee the
- * desired approximation error. The 'numSamplesMade' keeps track of the minimum
- * number of samples made by all queries in the node in question.
- */
-template<typename SortPolicy>
-class RAQueryStat
-{
- private:
-  //! The bound on the node's neighbor distances.
-  double bound;
-
-  //! The minimum number of samples made by any query in this node.
-  size_t numSamplesMade;
-
- public:
-  /**
-   * Initialize the statistic with the worst possible distance according to our
-   * sorting policy.
-   */
-  RAQueryStat() : bound(SortPolicy::WorstDistance()), numSamplesMade(0) { }
-
-  /**
-   * Initialization for a node.
-   */
-  template<typename TreeType>
-  RAQueryStat(const TreeType& /* node */) :
-    bound(SortPolicy::WorstDistance()),
-    numSamplesMade(0)
-  { }
-
-  //! Get the bound.
-  double Bound() const { return bound; }
-  //! Modify the bound.
-  double& Bound() { return bound; }
-
-  //! Get the number of samples made.
-  size_t NumSamplesMade() const { return numSamplesMade; }
-  //! Modify the number of samples made.
-  size_t& NumSamplesMade() { return numSamplesMade; }
-
-};
+#include "ra_query_stat.hpp"
 
 /**
  * The RASearch class: This class provides a generic manner to perform



More information about the mlpack-git mailing list