Skip to content

Commit e2fa430

Browse files
fix floating-point computation in create_cluster_tree
1 parent 3f9cc8f commit e2fa430

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ All notable changes to this project will be documented in this file.
4141
- Fix bug in task-based HLU, PR#81 thanks to @ABoisneault.
4242
- Fix `number_of_generated_coefficient` computation.
4343
- Fix overflow in `get_distributed_hmatrix_information`.
44+
- Fix float-point computation issue in `create_cluster_tree`.
4445

4546
## [1.0.2] - 2026-02-14
4647

include/htool/clustering/tree_builder/tree_builder.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ Cluster<T> ClusterTreeBuilder<T>::create_cluster_tree(int number_of_points, int
125125
} else {
126126
partition_type = Simple;
127127
if (size_partition >= number_of_children) {
128-
depth_of_partition = static_cast<int>(floor(log(size_partition) / log(number_of_children)));
128+
depth_of_partition = 0;
129+
int tmp = size_partition;
130+
while (tmp >= number_of_children) {
131+
tmp /= number_of_children;
132+
depth_of_partition++;
133+
}
129134
number_of_children_on_partition_level = number_of_children;
130135
if (size_partition != std::pow(number_of_children, depth_of_partition)) {
131136
Logger::get_instance().log(LogLevel::WARNING, "The given size for the partition is not a power of the number of children in the cluster tree.");

0 commit comments

Comments
 (0)