We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7263323 commit 9dff5ddCopy full SHA for 9dff5dd
include/svs/core/kmeans.h
@@ -45,6 +45,12 @@ Neighbor<size_t> find_nearest(const Query& query, const Data& data) {
45
auto d = distance::compute(f, query, data.get_datum(i));
46
nearest = std::min(nearest, Neighbor<size_t>(i, d));
47
}
48
+
49
+ // The case where the distance is infinity and the id remains unchanged from sentinel_v,
50
+ // reset to the first index to return to the exsiting neighbor.
51
+ if (nearest.id() >= data.size()) {
52
+ nearest = Neighbor<size_t>(0, nearest.distance());
53
+ }
54
return nearest;
55
56
0 commit comments