[mlpack-svn] r15018 - mlpack/trunk/src/mlpack/core/tree/binary_space_tree
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue May 7 15:38:35 EDT 2013
Author: rcurtin
Date: 2013-05-07 15:38:35 -0400 (Tue, 07 May 2013)
New Revision: 15018
Modified:
mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp
mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
Log:
Add NumDescendants() and Descendant() functions which will make things much
easier for range search and RANN.
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp 2013-05-07 16:01:19 UTC (rev 15017)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp 2013-05-07 19:38:35 UTC (rev 15018)
@@ -305,6 +305,22 @@
size_t NumPoints() const;
/**
+ * Return the number of descendants of this node. For a non-leaf in a binary
+ * space tree, this is the number of points at the descendant leaves. For a
+ * leaf, this is the number of points in the leaf.
+ */
+ size_t NumDescendants() const;
+
+ /**
+ * Return the index (with reference to the dataset) of a particular descendant
+ * of this node. The index should be greater than zero but less than the
+ * number of descendants.
+ *
+ * @param index Index of the descendant.
+ */
+ size_t Descendant(const size_t index) const;
+
+ /**
* Return the index (with reference to the dataset) of a particular point in
* this node. This will happily return invalid indices if the given index is
* greater than the number of points in this node (obtained with NumPoints())
@@ -329,7 +345,7 @@
//! Return the minimum and maximum distance to another node.
math::Range RangeDistance(const BinarySpaceTree* other) const
{
- return bound.RangeDistance(other);
+ return bound.RangeDistance(other->Bound());
}
//! Return the minimum distance to another point.
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp 2013-05-07 16:01:19 UTC (rev 15017)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp 2013-05-07 19:38:35 UTC (rev 15018)
@@ -416,6 +416,27 @@
}
/**
+ * Return the number of descendants contained in the node.
+ */
+template<typename BoundType, typename StatisticType, typename MatType>
+inline size_t
+BinarySpaceTree<BoundType, StatisticType, MatType>::NumDescendants() const
+{
+ return count;
+}
+
+/**
+ * Return the index of a particular descendant contained in this node.
+ */
+template<typename BoundType, typename StatisticType, typename MatType>
+inline size_t
+BinarySpaceTree<BoundType, StatisticType, MatType>::Descendant(
+ const size_t index) const
+{
+ return (begin + index);
+}
+
+/**
* Return the index of a particular point contained in this node.
*/
template<typename BoundType, typename StatisticType, typename MatType>
More information about the mlpack-svn
mailing list