Skip to content

Commit 31d41ce

Browse files
committed
component-wise abs is better
1 parent a27d0a3 commit 31d41ce

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cp-algo/util/simd.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ namespace cp_algo {
1818
using u8x32 = simd<uint8_t, 32>;
1919
using dx4 = simd<double, 4>;
2020

21-
inline dx4 abs(dx4 a) {
22-
return a < -a ? -a : a;
21+
dx4 abs(dx4 a) {
22+
return dx4{
23+
std::abs(a[0]),
24+
std::abs(a[1]),
25+
std::abs(a[2]),
26+
std::abs(a[3])
27+
};
2328
}
2429

2530
// https://stackoverflow.com/a/77376595

0 commit comments

Comments
 (0)