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 62 63
|
package slices
import _ "github.com/segmentio/asm/cpu"
// SumUint64 sums pairs of by index from x and y, similar to python's zip routine.
// If available AVX instructions will be used to operate on many uint64s simultaneously.
//
// Results are returned in the x slice and y is left unaltered. If x and y differ in size
// only len(x) elements will be processed.
func SumUint64(x []uint64, y []uint64) {
sumUint64(x, y)
}
func sumUint64Generic(x, y []uint64) {
for i := 0; i < len(x) && i < len(y); i++ {
x[i] = x[i] + y[i]
}
}
// SumUint32 sums pairs of by index from x and y, similar to python's zip routine.
// If available AVX instructions will be used to operate on many uint32s simultaneously.
//
// Results are returned in the x slice and y is left unaltered. If x and y differ in size
// only len(x) elements will be processed.
func SumUint32(x []uint32, y []uint32) {
sumUint32(x, y)
}
func sumUint32Generic(x, y []uint32) {
for i := 0; i < len(x) && i < len(y); i++ {
x[i] = x[i] + y[i]
}
}
// SumUint16 sums pairs of by index from x and y, similar to python's zip routine.
// If available AVX instructions will be used to operate on many uint16s simultaneously.
//
// Results are returned in the x slice and y is left unaltered. If x and y differ in size
// only len(x) elements will be processed.
func SumUint16(x []uint16, y []uint16) {
sumUint16(x, y)
}
func sumUint16Generic(x, y []uint16) {
for i := 0; i < len(x) && i < len(y); i++ {
x[i] = x[i] + y[i]
}
}
// SumUint8 sums pairs of by index from x and y, similar to python's zip routine.
// If available AVX instructions will be used to operate on many uint8s simultaneously.
//
// Results are returned in the x slice and y is left unaltered. If x and y differ in size
// only len(x) elements will be processed.
func SumUint8(x, y []uint8) {
sumUint8(x, y)
}
func sumUint8Generic(x, y []uint8) {
for i := 0; i < len(x) && i < len(y); i++ {
x[i] = x[i] + y[i]
}
}
|