mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 14:30:36 +00:00
renamed sort.hh to simd_sort.hh
This commit is contained in:
parent
a80f5cd532
commit
6372a965cf
2 changed files with 3 additions and 3 deletions
37
sort.hh
37
sort.hh
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
Sorting for SIMD types
|
||||
|
||||
Copyright 2024 Ahmet Inan <inan@aicodix.de>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
template <typename TYPE, int WIDTH>
|
||||
static inline SIMD<typename SIMD<TYPE, WIDTH>::uint_type, WIDTH> vorder(SIMD<TYPE, WIDTH> a)
|
||||
{
|
||||
SIMD<typename SIMD<TYPE, WIDTH>::uint_type, WIDTH> p;
|
||||
p.v[0] = 0;
|
||||
for (int i = 1, j; i < WIDTH; ++i) {
|
||||
TYPE t = a.v[i];
|
||||
for (j = i; j > 0 && a.v[j-1] > t; --j) {
|
||||
a.v[j] = a.v[j-1];
|
||||
p.v[j] = p.v[j-1];
|
||||
}
|
||||
a.v[j] = t;
|
||||
p.v[j] = i;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
template <typename TYPE, int WIDTH>
|
||||
static inline SIMD<TYPE, WIDTH> vsort(SIMD<TYPE, WIDTH> a)
|
||||
{
|
||||
for (int i = 1, j; i < WIDTH; ++i) {
|
||||
TYPE t = a.v[i];
|
||||
for (j = i; j > 0 && a.v[j-1] > t; --j)
|
||||
a.v[j] = a.v[j-1];
|
||||
a.v[j] = t;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue