for (int i = 0; i < points.size(); i++) {
if (!assignedIndices.get(i)) {
DoubleVector v = points.get(i);
List<VectorDistanceTuple<Integer>> neighbours = kdTree
.getNearestNeighbours(v, h);
DoubleVector center = new DenseDoubleVector(v.getLength());
int added = 0;
for (VectorDistanceTuple<Integer> neighbour : neighbours) {
if (!assignedIndices.get(neighbour.getValue())
&& neighbour.getDistance() < h) {
center = center.add(neighbour.getVector());
assignedIndices.set(neighbour.getValue());
added++;
}
}
// so if our sum is positive, we can divide and add the center
if (added > 1) {
DoubleVector newCenter = center.divide(added);
centers.add(newCenter);
if (verbose && centers.size() % 1000 == 0) {
LOG.info("#Centers found: " + centers.size());
}
}