[mlpack-svn] r12591 - mlpack/trunk/src/mlpack/core/tree
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue May 1 12:32:08 EDT 2012
Author: rcurtin
Date: 2012-05-01 12:32:08 -0400 (Tue, 01 May 2012)
New Revision: 12591
Modified:
mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp
mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
Log:
Add NumPoints() and Point() to BinarySpaceTree. Maybe Count() and Begin() could
be deprecated...?
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp 2012-05-01 16:16:02 UTC (rev 12590)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp 2012-05-01 16:32:08 UTC (rev 12591)
@@ -243,7 +243,20 @@
*/
BinarySpaceTree* Child(const size_t child) const;
+ //! Return the number of points in this node (0 if not a leaf).
+ size_t NumPoints() 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())
+ * -- be careful.
+ *
+ * @param index Index of point for which a dataset index is wanted.
+ */
+ size_t Point(const size_t index) const;
+
+ /**
* Returns the dimension this parent's children are split on.
*/
size_t GetSplitDimension() const;
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp 2012-05-01 16:16:02 UTC (rev 12590)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp 2012-05-01 16:32:08 UTC (rev 12591)
@@ -416,6 +416,30 @@
}
/**
+ * Return the number of points contained in this node.
+ */
+template<typename BoundType, typename StatisticType, typename MatType>
+inline size_t
+BinarySpaceTree<BoundType, StatisticType, MatType>::NumPoints() const
+{
+ if (left)
+ return 0;
+
+ return count;
+}
+
+/**
+ * Return the index of a particular point contained in this node.
+ */
+template<typename BoundType, typename StatisticType, typename MatType>
+inline size_t
+BinarySpaceTree<BoundType, StatisticType, MatType>::Point(const size_t index)
+ const
+{
+ return (begin + index);
+}
+
+/**
* Gets the index of the begin point of this subset.
*/
template<typename BoundType, typename StatisticType, typename MatType>
More information about the mlpack-svn
mailing list