Skip to content

Commit

Permalink
Merge pull request #220 from qq422216549/clz-nanoflann
Browse files Browse the repository at this point in the history
middleSplit_() speed up
  • Loading branch information
jlblancoc authored Dec 6, 2023
2 parents e0a9852 + 01f86fe commit 9b392a5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions include/nanoflann.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,25 +1307,26 @@ class KDTreeBaseClass
}
ElementType max_spread = -1;
cutfeat = 0;
ElementType min_elem = 0, max_elem = 0;
for (Dimension i = 0; i < dims; ++i)
{
ElementType span = bbox[i].high - bbox[i].low;
if (span > (1 - EPS) * max_span)
{
ElementType min_elem, max_elem;
computeMinMax(obj, ind, count, i, min_elem, max_elem);
ElementType spread = max_elem - min_elem;
ElementType min_elem_, max_elem_;
computeMinMax(obj, ind, count, i, min_elem_, max_elem_);
ElementType spread = max_elem_ - min_elem_;
if (spread > max_spread)
{
cutfeat = i;
max_spread = spread;
min_elem = min_elem_;
max_elem = max_elem_;
}
}
}
// split in the middle
DistanceType split_val = (bbox[cutfeat].low + bbox[cutfeat].high) / 2;
ElementType min_elem, max_elem;
computeMinMax(obj, ind, count, cutfeat, min_elem, max_elem);

if (split_val < min_elem)
cutval = min_elem;
Expand Down

0 comments on commit 9b392a5

Please sign in to comment.