Skip to content

Commit e4afcf3

Browse files
committed
Fix: Avoid std::accumulate
The `<numeric>` header that contains that function brings up to 2K lines of templates.
1 parent fbcab99 commit e4afcf3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/usearch/index_plugins.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -2453,8 +2453,9 @@ template <typename allocator_at = std::allocator<char>> class kmeans_clustering_
24532453
// Export stats.
24542454
result.iterations = iterations;
24552455
result.computed_distances = points_count * wanted_clusters * iterations;
2456-
result.aggregate_distance =
2457-
std::accumulate(point_to_centroid_distance_buffer.begin(), point_to_centroid_distance_buffer.end(), 0.0);
2456+
result.aggregate_distance = 0;
2457+
for (distance_t distance : point_to_centroid_distance_buffer)
2458+
result.aggregate_distance += distance;
24582459

24592460
// We've finished all the iterations, now we can export the centroids back to the original precision.
24602461
std::memcpy(point_to_centroid_index, point_to_centroid_index_buffer.data(), points_count * sizeof(std::size_t));

0 commit comments

Comments
 (0)