[mlpack-git] master: Make cleaner Armadillo expression. (ba826b1)

gitdub at mlpack.org gitdub at mlpack.org
Fri Apr 8 20:51:15 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/f0675d7789b69746f7c337c3ec4a778cef932924...ba826b1959a3f83532e91765b2bba0705e588d39

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

commit ba826b1959a3f83532e91765b2bba0705e588d39
Author: Ryan Curtin <ryan at ratml.org>
Date:   Fri Apr 8 20:51:15 2016 -0400

    Make cleaner Armadillo expression.


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

ba826b1959a3f83532e91765b2bba0705e588d39
 src/mlpack/tests/lsh_test.cpp | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/mlpack/tests/lsh_test.cpp b/src/mlpack/tests/lsh_test.cpp
index 52c0803..fae78e2 100644
--- a/src/mlpack/tests/lsh_test.cpp
+++ b/src/mlpack/tests/lsh_test.cpp
@@ -22,16 +22,8 @@ double ComputeRecall(
   const size_t queries = lshNeighbors.n_cols;
   const size_t neigh = lshNeighbors.n_rows;
 
-  size_t same = 0;
-  for (size_t q = 0; q < queries; ++q)
-  {
-    for (size_t n = 0; n < neigh; ++n)
-    {
-      same += (lshNeighbors(n, q) == groundTruth(n, q));
-    }
-  }
-  return static_cast<double>(same) /
-    (static_cast<double>(queries * neigh));
+  const double same = arma::accu(lshNeighbors == groundTruth);
+  return same / (static_cast<double>(queries * neigh));
 }
 
 BOOST_AUTO_TEST_SUITE(LSHTest);




More information about the mlpack-git mailing list