[mlpack-svn] r12719 - mlpack/trunk/src/mlpack/methods/maxip

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu May 17 23:30:20 EDT 2012


Author: rcurtin
Date: 2012-05-17 23:30:20 -0400 (Thu, 17 May 2012)
New Revision: 12719

Modified:
   mlpack/trunk/src/mlpack/methods/maxip/max_ip_impl.hpp
   mlpack/trunk/src/mlpack/methods/maxip/max_ip_rules_impl.hpp
Log:
unsafe_col() is faster.


Modified: mlpack/trunk/src/mlpack/methods/maxip/max_ip_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/maxip/max_ip_impl.hpp	2012-05-18 03:25:21 UTC (rev 12718)
+++ mlpack/trunk/src/mlpack/methods/maxip/max_ip_impl.hpp	2012-05-18 03:30:20 UTC (rev 12719)
@@ -91,8 +91,8 @@
     {
       for (size_t r = 0; r < referenceSet.n_cols; ++r)
       {
-        const double eval = KernelType::Evaluate(querySet.col(q),
-                                                 referenceSet.col(r));
+        const double eval = KernelType::Evaluate(querySet.unsafe_col(q),
+                                                 referenceSet.unsafe_col(r));
 
         size_t insertPosition;
         for (insertPosition = 0; insertPosition < indices.n_rows;

Modified: mlpack/trunk/src/mlpack/methods/maxip/max_ip_rules_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/maxip/max_ip_rules_impl.hpp	2012-05-18 03:25:21 UTC (rev 12718)
+++ mlpack/trunk/src/mlpack/methods/maxip/max_ip_rules_impl.hpp	2012-05-18 03:30:20 UTC (rev 12719)
@@ -40,8 +40,9 @@
   // and since we are using cover trees, p_0 is the point referred to by the
   // node, and R_p will be the expansion constant to the power of the scale plus
   // one.
-  const double eval = MetricType::Kernel::Evaluate(querySet.col(queryIndex),
-      referenceSet.col(referenceNode.Point()));
+  const double eval = MetricType::Kernel::Evaluate(
+      querySet.unsafe_col(queryIndex),
+      referenceSet.unsafe_col(referenceNode.Point()));
 
   // See if base case can be added.
   if (eval > products(products.n_rows - 1, queryIndex))
@@ -57,8 +58,8 @@
 
   double maxProduct = eval + std::pow(referenceNode.ExpansionConstant(),
       referenceNode.Scale() + 1) *
-      sqrt(MetricType::Kernel::Evaluate(querySet.col(queryIndex),
-      querySet.col(queryIndex)));
+      sqrt(MetricType::Kernel::Evaluate(querySet.unsafe_col(queryIndex),
+      querySet.unsafe_col(queryIndex)));
 
   if (maxProduct > products(products.n_rows - 1, queryIndex))
     return false;




More information about the mlpack-svn mailing list