/* Sorting for SIMD types Copyright 2024 Ahmet Inan */ #pragma once #include template static inline SIMD vorder(SIMD a) { SIMD tmp; for (int i = 0; i < WIDTH; ++i) tmp.v[i] = i; std::stable_sort(tmp.v, tmp.v+WIDTH, [a](int i, int j){ return a.v[i] < a.v[j]; }); return tmp; } template static inline SIMD vorder(SIMD a) { SIMD tmp; for (int i = 0; i < WIDTH; ++i) tmp.v[i] = i; std::stable_sort(tmp.v, tmp.v+WIDTH, [a](int i, int j){ return a.v[i] < a.v[j]; }); return tmp; } template static inline SIMD vorder(SIMD a) { SIMD tmp; for (int i = 0; i < WIDTH; ++i) tmp.v[i] = i; std::stable_sort(tmp.v, tmp.v+WIDTH, [a](int i, int j){ return a.v[i] < a.v[j]; }); return tmp; } template static inline SIMD vorder(SIMD a) { SIMD tmp; for (int i = 0; i < WIDTH; ++i) tmp.v[i] = i; std::stable_sort(tmp.v, tmp.v+WIDTH, [a](int i, int j){ return a.v[i] < a.v[j]; }); return tmp; } template static inline SIMD vorder(SIMD a) { SIMD tmp; for (int i = 0; i < WIDTH; ++i) tmp.v[i] = i; std::stable_sort(tmp.v, tmp.v+WIDTH, [a](int i, int j){ return a.v[i] < a.v[j]; }); return tmp; } template static inline SIMD vorder(SIMD a) { SIMD tmp; for (int i = 0; i < WIDTH; ++i) tmp.v[i] = i; std::stable_sort(tmp.v, tmp.v+WIDTH, [a](int i, int j){ return a.v[i] < a.v[j]; }); return tmp; } template static inline SIMD vsort(SIMD a) { std::sort(a.v, a.v+WIDTH); return a; } template static inline SIMD vsort(SIMD a) { std::sort(a.v, a.v+WIDTH); return a; } template static inline SIMD vsort(SIMD a) { std::sort(a.v, a.v+WIDTH); return a; } template static inline SIMD vsort(SIMD a) { std::sort(a.v, a.v+WIDTH); return a; } template static inline SIMD vsort(SIMD a) { std::sort(a.v, a.v+WIDTH); return a; } template static inline SIMD vsort(SIMD a) { std::sort(a.v, a.v+WIDTH); return a; }