[mlpack-git] master: Handle zero-size cover trees... sort of. (3f4e6a8)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Mon Oct 19 16:04:52 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/09cd0d67f2fdae252a8ab85324e71dbb4dfe0010...fecf1194c123ced12d56e7daad761c7b9aaac262

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

commit 3f4e6a84e9cc42749fee0441675e8eae738ba330
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Oct 19 16:01:48 2015 -0400

    Handle zero-size cover trees... sort of.


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

3f4e6a84e9cc42749fee0441675e8eae738ba330
 src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp b/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
index 93d146e..65a2d63 100644
--- a/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
+++ b/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
@@ -44,8 +44,9 @@ CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::CoverTree(
   if (localMetric)
     this->metric = new MetricType();
 
-  // If there is only one point in the dataset... uh, we're done.
-  if (dataset.n_cols == 1)
+  // If there is only one point or zero points in the dataset... uh, we're done.
+  // Technically, if the dataset has zero points, our node is not correct...
+  if (dataset.n_cols <= 1)
     return;
 
   // Kick off the building.  Create the indices array and the distances array.
@@ -128,8 +129,9 @@ CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::CoverTree(
     metric(&metric),
     distanceComps(0)
 {
-  // If there is only one point in the dataset, uh, we're done.
-  if (dataset.n_cols == 1)
+  // If there is only one point or zero points in the dataset... uh, we're done.
+  // Technically, if the dataset has zero points, our node is not correct...
+  if (dataset.n_cols <= 1)
     return;
 
   // Kick off the building.  Create the indices array and the distances array.
@@ -214,8 +216,9 @@ CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::CoverTree(
   // We need to create a metric.  We'll just do it on the heap.
   this->metric = new MetricType();
 
-  // If there is only one point in the dataset... uh, we're done.
-  if (dataset->n_cols == 1)
+  // If there is only one point or zero points in the dataset... uh, we're done.
+  // Technically, if the dataset has zero points, our node is not correct...
+  if (dataset->n_cols <= 1)
     return;
 
   // Kick off the building.  Create the indices array and the distances array.
@@ -298,8 +301,9 @@ CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::CoverTree(
     metric(&metric),
     distanceComps(0)
 {
-  // If there is only one point in the dataset... uh, we're done.
-  if (dataset->n_cols == 1)
+  // If there is only one point or zero points in the dataset... uh, we're done.
+  // Technically, if the dataset has zero points, our node is not correct...
+  if (dataset->n_cols <= 1)
     return;
 
   // Kick off the building.  Create the indices array and the distances array.



More information about the mlpack-git mailing list