[mlpack-svn] r13363 - mlpack/trunk/src/mlpack/core/tree/cover_tree

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Aug 7 18:37:20 EDT 2012


Author: rcurtin
Date: 2012-08-07 18:37:20 -0400 (Tue, 07 Aug 2012)
New Revision: 13363

Modified:
   mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
Log:
Tighten bounds on minimum and maximum distances because we already cached the
furthest distance.


Modified: mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp	2012-08-07 19:56:54 UTC (rev 13362)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp	2012-08-07 22:37:20 UTC (rev 13363)
@@ -426,8 +426,7 @@
   // Every cover tree node will contain points up to EC^(scale + 1) away.
   return std::max(MetricType::Evaluate(dataset.unsafe_col(point),
       other->Dataset().unsafe_col(other->Point())) -
-      std::pow(expansionConstant, scale + 1) -
-      std::pow(other->ExpansionConstant(), other->Scale() + 1), 0.0);
+      furthestDescendantDistance - other->FurthestDescendantDistance(), 0.0);
 }
 
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
@@ -436,8 +435,8 @@
     const double distance) const
 {
   // We already have the distance as evaluated by the metric.
-  return std::max(distance - (std::pow(expansionConstant, scale + 1) -
-      std::pow(other->ExpansionConstant(), other->Scale() + 1)), 0.0);
+  return std::max(distance - furthestDescendantDistance -
+      other->FurthestDescendantDistance(), 0.0);
 }
 
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
@@ -445,7 +444,7 @@
     const arma::vec& other) const
 {
   return std::max(MetricType::Evaluate(dataset.unsafe_col(point), other) -
-      std::pow(expansionConstant, scale + 1), 0.0);
+      furthestDescendantDistance, 0.0);
 }
 
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
@@ -453,7 +452,7 @@
     const arma::vec& other,
     const double distance) const
 {
-  return std::max(distance - std::pow(expansionConstant, scale + 1), 0.0);
+  return std::max(distance - furthestDescendantDistance, 0.0);
 }
 
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
@@ -462,8 +461,7 @@
 {
   return MetricType::Evaluate(dataset.unsafe_col(point),
       other->Dataset().unsafe_col(other->Point())) +
-      std::pow(expansionConstant, scale + 1) +
-      std::pow(other->ExpansionConstant(), other->Scale() + 1);
+      furthestDescendantDistance + other->FurthestDescendantDistance();
 }
 
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
@@ -472,8 +470,8 @@
     const double distance) const
 {
   // We already have the distance as evaluated by the metric.
-  return distance + (std::pow(expansionConstant, scale + 1) +
-      std::pow(other->ExpansionConstant(), other->Scale() + 1));
+  return distance + furthestDescendantDistance +
+      other->FurthestDescendantDistance();
 }
 
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
@@ -481,7 +479,7 @@
     const arma::vec& other) const
 {
   return MetricType::Evaluate(dataset.unsafe_col(point), other) +
-      std::pow(expansionConstant, scale + 1);
+      furthestDescendantDistance;
 }
 
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
@@ -489,7 +487,7 @@
     const arma::vec& other,
     const double distance) const
 {
-  return distance + std::pow(expansionConstant, scale + 1);
+  return distance + furthestDescendantDistance;
 }
 
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>




More information about the mlpack-svn mailing list