[mlpack] 10/53: Don't return duplicate points.

Barak A. Pearlmutter barak+git at pearlmutter.net
Mon Nov 14 00:46:46 UTC 2016


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch master
in repository mlpack.

commit 680f59bab89929098c8890b4499cd7303727fc5e
Author: Ryan Curtin <ryan at ratml.org>
Date:   Tue Apr 19 13:43:17 2016 -0700

    Don't return duplicate points.
---
 qdafn_impl.hpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/qdafn_impl.hpp b/qdafn_impl.hpp
index 368b84c..47a698c 100644
--- a/qdafn_impl.hpp
+++ b/qdafn_impl.hpp
@@ -104,9 +104,18 @@ void QDAFN<MatType>::Search(const MatType& querySet,
       const size_t insertPosition =
           mlpack::neighbor::FurthestNeighborSort::SortDistance(queryDist,
           queryIndices, dist);
+      bool found = false;
+      for (size_t j = 0; j < neighbors.n_rows; ++j)
+      {
+        if (neighbors(j, q) == referenceIndex)
+        {
+          found = true;
+          break;
+        }
+      }
 
       // SortDistance() returns (size_t() - 1) if we shouldn't add it.
-      if (insertPosition != (size_t() - 1))
+      if (insertPosition != (size_t() - 1) && !found)
         InsertNeighbor(distances, neighbors, q, insertPosition, referenceIndex,
             dist);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list