Skip to content

Commit

Permalink
Merge pull request #1067 from aprokop/minor_fix
Browse files Browse the repository at this point in the history
Exit early from unionFindWithingEachDistanceCell when n <= 1
  • Loading branch information
aprokop authored Apr 15, 2024
2 parents 4ec9bd0 + 419c5a4 commit d264a9d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/details/ArborX_DetailsFDBSCANDenseBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,17 @@ void unionFindWithinEachDenseCell(ExecutionSpace const &exec_space,
CellIndices sorted_dense_cell_indices,
Permutation permute, UnionFind union_find)
{
auto const n = sorted_dense_cell_indices.size();
if (n <= 1)
return;

// The algorithm relies on the fact that the cell indices array only contains
// dense cells. Thus, as long as two cell indices are the same, a) they
// belong to the same cell, and b) that cell is dense, thus they should be in
// the same cluster. If, on the other hand, the array also contained
// non-dense cells, that would not have been possible, as an additional
// computations would have to be done to figure out if the points belong to a
// dense cell, which would have required a linear scan.
auto const n = sorted_dense_cell_indices.size();
Kokkos::parallel_for(
"ArborX::DBSCAN::union_find_within_each_dense_box",
Kokkos::RangePolicy<ExecutionSpace>(exec_space, 1, n),
Expand Down

0 comments on commit d264a9d

Please sign in to comment.