-
Notifications
You must be signed in to change notification settings - Fork 1
/
purego.go
61 lines (54 loc) · 1.24 KB
/
purego.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package vectorcmp
func goVectorEquals[T uint8 | uint16 | uint32 | uint64 | float32 | float64](dst []byte, search T, rows []T) {
zero(dst)
for i, v := range rows {
if search == v {
dst[i/8] |= 1 << (i % 8)
}
}
}
func goVectorGreaterThan[T uint8 | uint16 | uint32 | uint64 | float32 | float64](dst []byte, search T, rows []T) {
zero(dst)
for i, v := range rows {
if search > v {
dst[i/8] |= 1 << (i % 8)
}
}
}
func goVectorLessThan[T uint8 | uint16 | uint32 | uint64 | float32 | float64](dst []byte, search T, rows []T) {
zero(dst)
for i, v := range rows {
if search < v {
dst[i/8] |= 1 << (i % 8)
}
}
}
func goVectorGreaterEquals[T uint8 | uint16 | uint32 | uint64 | float32 | float64](dst []byte, search T, rows []T) {
zero(dst)
for i, v := range rows {
if search >= v {
dst[i/8] |= 1 << (i % 8)
}
}
}
func goVectorLesserEquals[T uint8 | uint16 | uint32 | uint64 | float32 | float64](dst []byte, search T, rows []T) {
zero(dst)
for i, v := range rows {
if search <= v {
dst[i/8] |= 1 << (i % 8)
}
}
}
func goVectorIsNaN[T float32 | float64](dst []byte, rows []T) {
zero(dst)
for i, v := range rows {
if v != v {
dst[i/8] |= 1 << (i % 8)
}
}
}
func zero(dst []byte) {
for i := range dst {
dst[i] = 0
}
}