Skip to content

Commit 42f77ea

Browse files
committed
Use map instead of unordered_map to avoid expensive hashing of floating point numbers
1 parent 8d04430 commit 42f77ea

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

cpp/src/dual_simplex/folding.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* clang-format off */
22
/*
3-
* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
/* clang-format on */
@@ -9,6 +9,7 @@
99

1010
#include <dual_simplex/tic_toc.hpp>
1111

12+
#include <map>
1213
#include <numeric>
1314
#include <unordered_map>
1415
#include <unordered_set>
@@ -224,8 +225,8 @@ void split_colors(i_t color,
224225
i_t refining_color,
225226
int8_t side_being_split,
226227
std::vector<f_t>& vertex_to_sum,
227-
std::unordered_map<f_t, std::vector<i_t>>& color_sums,
228-
std::unordered_map<f_t, i_t>& sum_to_sizes,
228+
std::map<f_t, std::vector<i_t>>& color_sums,
229+
std::map<f_t, i_t>& sum_to_sizes,
229230
std::vector<color_t<i_t>>& colors,
230231
std::vector<i_t>& color_stack,
231232
std::vector<i_t>& color_in_stack,
@@ -458,8 +459,8 @@ i_t color_graph(const csc_matrix_t<i_t, f_t>& A,
458459
color_in_stack[0] = 1;
459460
color_in_stack[1] = 1;
460461

461-
std::unordered_map<f_t, std::vector<i_t>> color_sums;
462-
std::unordered_map<f_t, i_t> sum_to_sizes;
462+
std::map<f_t, std::vector<i_t>> color_sums;
463+
std::map<f_t, i_t> sum_to_sizes;
463464

464465
std::vector<std::vector<i_t>> vertices_to_refine_by_color(max_colors);
465466
std::vector<f_t> max_sum_by_color(max_colors, std::numeric_limits<f_t>::quiet_NaN());

0 commit comments

Comments
 (0)