We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1078cbb commit ed7c725Copy full SHA for ed7c725
cp-algo/util/simd.hpp
@@ -17,6 +17,16 @@ namespace cp_algo {
17
return a < 0 ? -a : a;
18
}
19
20
+ // https://stackoverflow.com/a/77376595
21
+ // works for ints in (-2^51, 2^51)
22
+ static constexpr dx4 magic = dx4() + (3ULL << 51);
23
+ [[gnu::always_inline]] inline i64x4 lround(dx4 x) {
24
+ return i64x4(x + magic) - i64x4(magic);
25
+ }
26
+ [[gnu::always_inline]] inline dx4 to_double(i64x4 x) {
27
+ return dx4(x + i64x4(magic)) - magic;
28
29
+
30
[[gnu::always_inline]] inline dx4 round(dx4 a) {
31
return dx4{
32
std::nearbyint(a[0]),
0 commit comments