78 48, 33, 27, 34, 47, 78, 28, 77,
79 66, 29, 51, 52, 65, 30, 72, 63,
80 76, 95, 75, 24, 53, 54, 82, 81,
81 18, 3, 17, 80, 61, 4, 62, 15,
82 0, 59, 71, 60, 49, 50, 86, 85,
83 84, 83, 5, 90, 79, 56, 6, 89,
84 32, 23, 1, 94, 11, 12, 2, 93,
85 42, 41, 13, 14, 35, 88, 36, 31,
86 92, 37, 87, 38, 91, 74, 8, 73,
87 46, 45, 9, 10, 7, 20, 64, 19,
88 70, 25, 39, 16, 69, 26, 44, 43,
89 22, 55, 21, 68, 57, 40, 58, 67,
165 double min_x = coords[0], max_x = coords[0];
166 double min_y = coords[1], max_y = coords[1];
167 double min_z = coords[2], max_z = coords[2];
169 for (
size_t i = 1; i < n_atoms; ++i) {
170 double x = coords[i * 3];
171 double y = coords[i * 3 + 1];
172 double z = coords[i * 3 + 2];
173 min_x = std::min(min_x,
x);
174 max_x = std::max(max_x,
x);
175 min_y = std::min(min_y,
y);
176 max_y = std::max(max_y,
y);
177 min_z = std::min(min_z,
z);
178 max_z = std::max(max_z,
z);
183 std::max({max_x - min_x, max_y - min_y, max_z - min_z, 1e-12});
184 double min_coord = std::min({min_x, min_y, min_z});
187 std::vector<std::pair<uint32_t, size_t>> indexed(n_atoms);
188 for (
size_t i = 0; i < n_atoms; ++i) {
189 double x = coords[i * 3];
190 double y = coords[i * 3 + 1];
191 double z = coords[i * 3 + 2];
192 indexed[i] = {
hilbert_3d(
x,
y,
z, min_coord, scale, bits), i};
196 std::sort(indexed.begin(), indexed.end());
199 std::vector<size_t> perm(n_atoms);
200 for (
size_t i = 0; i < n_atoms; ++i) {
201 perm[i] = indexed[i].second;