[mlpack-git] master: Add new element to TreeTraits, to know if NumDescendants() includes duplicated points. (3b15fdf)

gitdub at mlpack.org gitdub at mlpack.org
Thu Aug 11 09:56:45 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/0f4b25acd6aaa14294c044874ba6cc0751712baa...0a19d07bd39e6223991976474bc79671ba8aa0f0

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

commit 3b15fdff5817e124b1a33c1dd390da71b2fce8c0
Author: MarcosPividori <marcos.pividori at gmail.com>
Date:   Thu Aug 11 10:56:45 2016 -0300

    Add new element to TreeTraits, to know if NumDescendants() includes duplicated points.


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

3b15fdff5817e124b1a33c1dd390da71b2fce8c0
 src/mlpack/core/tree/binary_space_tree/traits.hpp |  7 +++++++
 src/mlpack/core/tree/cover_tree/traits.hpp        |  5 +++++
 src/mlpack/core/tree/rectangle_tree/traits.hpp    | 12 ++++++++++++
 src/mlpack/core/tree/spill_tree/traits.hpp        |  6 ++++++
 src/mlpack/core/tree/tree_traits.hpp              |  6 ++++++
 src/mlpack/methods/rann/ra_search_rules.hpp       |  3 +++
 6 files changed, 39 insertions(+)

diff --git a/src/mlpack/core/tree/binary_space_tree/traits.hpp b/src/mlpack/core/tree/binary_space_tree/traits.hpp
index 9a81673..5356ef0 100644
--- a/src/mlpack/core/tree/binary_space_tree/traits.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/traits.hpp
@@ -55,6 +55,12 @@ class TreeTraits<BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
    * This is always a binary tree.
    */
   static const bool BinaryTree = true;
+
+  /**
+   * Binary space trees don't have duplicated points, so NumDescendants()
+   * represents the number of unique descendant points.
+   */
+  static const bool UniqueNumDescendants = true;
 };
 
 /**
@@ -78,6 +84,7 @@ class TreeTraits<BinarySpaceTree<MetricType, StatisticType, MatType,
   static const bool HasSelfChildren = false;
   static const bool RearrangesDataset = true;
   static const bool BinaryTree = true;
+  static const bool UniqueNumDescendants = true;
 };
 
 } // namespace tree
diff --git a/src/mlpack/core/tree/cover_tree/traits.hpp b/src/mlpack/core/tree/cover_tree/traits.hpp
index a88c08f..9f2fb80 100644
--- a/src/mlpack/core/tree/cover_tree/traits.hpp
+++ b/src/mlpack/core/tree/cover_tree/traits.hpp
@@ -52,6 +52,11 @@ class TreeTraits<CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>>
    * The cover tree is not necessarily a binary tree.
    */
   static const bool BinaryTree = false;
+
+  /**
+   * NumDescendants() represents the number of unique descendant points.
+   */
+  static const bool UniqueNumDescendants = true;
 };
 
 } // namespace tree
diff --git a/src/mlpack/core/tree/rectangle_tree/traits.hpp b/src/mlpack/core/tree/rectangle_tree/traits.hpp
index e4e16f9..72bb737 100644
--- a/src/mlpack/core/tree/rectangle_tree/traits.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/traits.hpp
@@ -54,6 +54,12 @@ class TreeTraits<RectangleTree<MetricType, StatisticType, MatType, SplitType,
    * This tree is not necessarily a binary tree.
    */
   static const bool BinaryTree = false;
+
+  /**
+   * Rectangle trees don't have duplicated points, so NumDescendants()
+   * represents the number of unique descendant points.
+   */
+  static const bool UniqueNumDescendants = true;
 };
 
 /**
@@ -102,6 +108,12 @@ class TreeTraits<RectangleTree<MetricType,
    * This tree is not necessarily a binary tree.
    */
   static const bool BinaryTree = false;
+
+  /**
+   * Rectangle trees don't have duplicated points, so NumDescendants()
+   * represents the number of unique descendant points.
+   */
+  static const bool UniqueNumDescendants = true;
 };
 
 } // namespace tree
diff --git a/src/mlpack/core/tree/spill_tree/traits.hpp b/src/mlpack/core/tree/spill_tree/traits.hpp
index bd28953..f3bf262 100644
--- a/src/mlpack/core/tree/spill_tree/traits.hpp
+++ b/src/mlpack/core/tree/spill_tree/traits.hpp
@@ -54,6 +54,12 @@ class TreeTraits<SpillTree<MetricType, StatisticType, MatType, HyperplaneType,
    * This is always a binary tree.
    */
   static const bool BinaryTree = true;
+
+  /**
+   * Spill trees have duplicated points, so NumDescendants() could count a given
+   * point twice.
+   */
+  static const bool UniqueNumDescendants = false;
 };
 
 } // namespace tree
diff --git a/src/mlpack/core/tree/tree_traits.hpp b/src/mlpack/core/tree/tree_traits.hpp
index cb005e6..c4427d9 100644
--- a/src/mlpack/core/tree/tree_traits.hpp
+++ b/src/mlpack/core/tree/tree_traits.hpp
@@ -98,6 +98,12 @@ class TreeTraits
    * This is true if the tree always has only two children.
    */
   static const bool BinaryTree = false;
+
+  /**
+   * This is true if the NumDescendants() method doesn't include duplicated
+   * points.
+   */
+  static const bool UniqueNumDescendants = true;
 };
 
 } // namespace tree
diff --git a/src/mlpack/methods/rann/ra_search_rules.hpp b/src/mlpack/methods/rann/ra_search_rules.hpp
index a07577c..c47934b 100644
--- a/src/mlpack/methods/rann/ra_search_rules.hpp
+++ b/src/mlpack/methods/rann/ra_search_rules.hpp
@@ -317,6 +317,9 @@ class RASearchRules
                TreeType& referenceNode,
                const double distance,
                const double bestDistance);
+
+  static_assert(tree::TreeTraits<TreeType>::UniqueNumDescendants, "TreeType "
+      "must provide a unique number of descendants points.");
 }; // class RASearchRules
 
 } // namespace neighbor




More information about the mlpack-git mailing list