Pseudorandom permutation within set of numbers with the same log2(x).
| 186 | |
| 187 | /// Pseudorandom permutation within set of numbers with the same log2(x). |
| 188 | static UInt64 transform(UInt64 x, UInt64 seed) |
| 189 | { |
| 190 | /// Keep 0 and 1 as is. |
| 191 | if (x == 0 || x == 1) |
| 192 | return x; |
| 193 | |
| 194 | /// Pseudorandom permutation of two elements. |
| 195 | if (x == 2 || x == 3) |
| 196 | return x ^ (seed & 1); |
| 197 | |
| 198 | size_t num_leading_zeros = std::countl_zero(x); |
| 199 | |
| 200 | return feistelNetwork(x, 64 - num_leading_zeros - 1, seed); |
| 201 | } |
| 202 | |
| 203 | |
| 204 | class UnsignedIntegerModel : public IModel |