simd

package standard library
go1.27rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package simd implements portable and vector-size-agnostic SIMD types, and functions and methods for working with these types. SIMD types are either implemented in hardware (for example, arm64 "Neon" or amd64 "AVX/AVX2/AVX512") using the corresponding types in the simd/archsimd package, or emulated in pure Go. In all cases, the vector length is at least 128 bits, and within a given program execution, all vectors have the same length.

SIMD Types

There is a simd type corresponding to each primitive numeric type, except for complex64 and complex128. Each of these is the type name, capitalized, with an "s" suffix, for example Int8s, Uint16s, or Float64s.

There are also simd "mask" types that abstract the mask registers present in some architectures, otherwise these will be implemented as bit masks.

Obtaining SIMD values

The zero value of a SIMD vector type is valid and represents a zero vector.

For each SIMD type, "Load<Types>(s []<type>) <Types>" loads a full verctor of the type from a long-enough slice.

For slices that are not long enough, "Load<Types>Part(s []<type>) (<Types>, int)" will load as many elements as are available from the slice, fill the remainder with zero, and also return the number that were loaded.

For each SIMD type, "Broadcast<Types>(x type) <Types>" returns a vector whose elements are all initialized to x.

Examples:

Operations

SIMD types provide methods for unary (Float32s.Abs, Int16s.Not), binary (Float64s.Add, Uint32s.GreaterEqual), and ternary operations (Int64s.IfElse, Float32s.MulAdd). Relational operations produce masks.

SIMD types also support conversions between types, both those that are mostly value-preserving (Int32s.ConvertToFloat32, Float32s.ConvertToInt32) and those that change types without altering the underlying vector bit pattern.

Signed integer types convert to mask types (Int16s.ToMask), but this is a comparison against zero, not a simple bitwise conversion. Mask types convert to signed integers in an operation (Mask32s.ToInt32s) that may be a zero-cost bitwise conversion, or not, depending on the underlying hardware.

Storing

SIMD vector types have two methods, one for storing the entire vector into a slice "Store([]<type>)"" and a second for storing part of a vector into a slice "StorePart([]<type>) int". StorePart returns the number of elements actually stored.

String conversion

Vectors and masks provide a String method for conversion to strings.

Conversion to and from simd/archsimd types.

Each SIMD vector type has a "ToArch() any" method that returns the type supported by the current hardware as an "any". Code using these methods must be build-tagged to the relevant architecture(s) and type-assert the returned value to the appropriate type.

The simd package also includes generic functions for converting an architecture-dependent simd/archsimd value (e.g. archsimd.Float32x4) into the corresponding simd type. This function will panic if the correspondence is incorrect.

For an example of converting between simd and arch/simd types, see the test file sum_amd64_test.go.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emulated

func Emulated() bool

Emulated returns whether simd operations are emulated or running on actual vector hardware.

func HasHardwareCarrylessMultiply

func HasHardwareCarrylessMultiply() bool

HasHardwareCarrylessMultiply returns whether this platform as a hardware-implemented version of carryless multiply. With default GODEBUG=simd settings, if this is false, it is emulated and merely slow, but with non-default settings this can indicate the possibility of a missing instruction that will fail ("SIGILL") if it is executed.

func VectorBitSize

func VectorBitSize() int

VectorBitSize returns the bit length of the longest vector available on the current hardware. It can be artificially reduced by setting GODEBUG=simd=<smaller size> environment variable before running a program.

Types

type Float32s

type Float32s struct {
	// contains filtered or unexported fields
}

Float32s represents a vector of 32-bit floating-point numbers.

func BroadcastFloat32s

func BroadcastFloat32s(float32) Float32s

BroadcastFloat32 fills the elements of a slice with its argument value.

func Float32sFromArch

func Float32sFromArch[T archSimdFloat32s](x T) Float32s

func LoadFloat32s

func LoadFloat32s([]float32) Float32s

LoadFloat32 loads a slice of float32 into an Float32s vector.

func LoadFloat32sPart

func LoadFloat32sPart([]float32) (Float32s, int)

LoadFloat32Part loads a partial slice of float32 into an Float32s vector, returning the vector and the number of elements loaded.

func (Float32s) Abs

func (x Float32s) Abs() Float32s

Abs returns the element-wise absolute value of x.

func (Float32s) Add

func (x Float32s) Add(y Float32s) Float32s

Add returns the element-wise sum of x and y.

func (Float32s) ConvertToInt32

func (x Float32s) ConvertToInt32() Int32s

ConvertToInt32 converts the vector elements to int32.

func (Float32s) Div

func (x Float32s) Div(y Float32s) Float32s

Div returns the element-wise quotient of x and y.

func (Float32s) Equal

func (x Float32s) Equal(y Float32s) Mask32s

Equal returns a mask indicating where x and y are equal.

func (Float32s) Greater

func (x Float32s) Greater(y Float32s) Mask32s

Greater returns a mask indicating where x is greater than y.

func (Float32s) GreaterEqual

func (x Float32s) GreaterEqual(y Float32s) Mask32s

GreaterEqual returns a mask indicating where x is greater than or equal to y.

func (Float32s) IfElse

func (x Float32s) IfElse(mask Mask32s, y Float32s) Float32s

IfElse returns a new vector with elements from x where mask is true, and y where mask is false.

func (Float32s) Len

func (x Float32s) Len() int

Len returns the number of elements in the vector.

func (Float32s) Less

func (x Float32s) Less(y Float32s) Mask32s

Less returns a mask indicating where x is less than y.

func (Float32s) LessEqual

func (x Float32s) LessEqual(y Float32s) Mask32s

LessEqual returns a mask indicating where x is less than or equal to y.

func (Float32s) Masked

func (x Float32s) Masked(mask Mask32s) Float32s

Masked returns a new vector with elements from x where mask is true, and zero elsewhere.

func (Float32s) Max

func (x Float32s) Max(y Float32s) Float32s

Max returns the element-wise maximum of x and y.

func (Float32s) Min

func (x Float32s) Min(y Float32s) Float32s

Min returns the element-wise minimum of x and y.

func (Float32s) Mul

func (x Float32s) Mul(y Float32s) Float32s

Mul returns the element-wise product of x and y.

func (Float32s) MulAdd

func (x Float32s) MulAdd(y Float32s, z Float32s) Float32s

MulAdd returns x * y + z element-wise.

Example
package main

import (
	"fmt"
	"simd"
)

func main() {
	// Float32s on 512-bit vector has 16 elements.
	v1 := simd.LoadFloat32s([]float32{
		1.5, 2.5, 3.5, 4.5,
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0,
	})
	v2 := simd.LoadFloat32s([]float32{
		2.0, 2.0, 2.0, 2.0,
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0,
	})
	v3 := simd.LoadFloat32s([]float32{
		1.0, 2.0, 3.0, 4.0,
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0,
	})

	// Perform element-wise v1 * v2 + v3.
	res := v1.MulAdd(v2, v3)

	out := make([]float32, res.Len())
	res.Store(out)

	// Print the first 4 elements.
	fmt.Println(out[:4])
}
Output:
[4 7 10 13]

func (Float32s) Neg

func (x Float32s) Neg() Float32s

Neg returns the element-wise negation of x.

func (Float32s) NotEqual

func (x Float32s) NotEqual(y Float32s) Mask32s

NotEqual returns a mask indicating where x and y are not equal.

func (Float32s) Sqrt

func (x Float32s) Sqrt() Float32s

Sqrt returns the element-wise square root of x.

func (Float32s) Store

func (x Float32s) Store(s []float32)

Store stores the vector elements into the slice s.

func (Float32s) StorePart

func (x Float32s) StorePart(s []float32) int

StorePart stores a partial vector into the slice s and returns the number actually stored.

func (Float32s) String

func (x Float32s) String() string

String returns a string representation of the vector.

func (Float32s) Sub

func (x Float32s) Sub(y Float32s) Float32s

Sub returns the element-wise difference of x and y.

func (Float32s) ToArch

func (x Float32s) ToArch() any

func (Float32s) ToBits

func (x Float32s) ToBits() Uint32s

ToBits reinterprets the vector bits as an unsigned integer vector.

type Float64s

type Float64s struct {
	// contains filtered or unexported fields
}

Float64s represents a vector of 64-bit floating-point numbers.

func BroadcastFloat64s

func BroadcastFloat64s(float64) Float64s

BroadcastFloat64 fills the elements of a slice with its argument value.

func Float64sFromArch

func Float64sFromArch[T archSimdFloat64s](x T) Float64s

func LoadFloat64s

func LoadFloat64s([]float64) Float64s

LoadFloat64 loads a slice of float64 into an Float64s vector.

func LoadFloat64sPart

func LoadFloat64sPart([]float64) (Float64s, int)

LoadFloat64Part loads a partial slice of float64 into an Float64s vector, returning the vector and the number of elements loaded.

func (Float64s) Abs

func (x Float64s) Abs() Float64s

Abs returns the element-wise absolute value of x.

func (Float64s) Add

func (x Float64s) Add(y Float64s) Float64s

Add returns the element-wise sum of x and y.

func (Float64s) Div

func (x Float64s) Div(y Float64s) Float64s

Div returns the element-wise quotient of x and y.

func (Float64s) Equal

func (x Float64s) Equal(y Float64s) Mask64s

Equal returns a mask indicating where x and y are equal.

func (Float64s) Greater

func (x Float64s) Greater(y Float64s) Mask64s

Greater returns a mask indicating where x is greater than y.

func (Float64s) GreaterEqual

func (x Float64s) GreaterEqual(y Float64s) Mask64s

GreaterEqual returns a mask indicating where x is greater than or equal to y.

func (Float64s) IfElse

func (x Float64s) IfElse(mask Mask64s, y Float64s) Float64s

IfElse returns a new vector with elements from x where mask is true, and y where mask is false.

func (Float64s) Len

func (x Float64s) Len() int

Len returns the number of elements in the vector.

func (Float64s) Less

func (x Float64s) Less(y Float64s) Mask64s

Less returns a mask indicating where x is less than y.

func (Float64s) LessEqual

func (x Float64s) LessEqual(y Float64s) Mask64s

LessEqual returns a mask indicating where x is less than or equal to y.

func (Float64s) Masked

func (x Float64s) Masked(mask Mask64s) Float64s

Masked returns a new vector with elements from x where mask is true, and zero elsewhere.

func (Float64s) Max

func (x Float64s) Max(y Float64s) Float64s

Max returns the element-wise maximum of x and y.

func (Float64s) Min

func (x Float64s) Min(y Float64s) Float64s

Min returns the element-wise minimum of x and y.

func (Float64s) Mul

func (x Float64s) Mul(y Float64s) Float64s

Mul returns the element-wise product of x and y.

func (Float64s) MulAdd

func (x Float64s) MulAdd(y Float64s, z Float64s) Float64s

MulAdd returns x * y + z element-wise.

func (Float64s) Neg

func (x Float64s) Neg() Float64s

Neg returns the element-wise negation of x.

func (Float64s) NotEqual

func (x Float64s) NotEqual(y Float64s) Mask64s

NotEqual returns a mask indicating where x and y are not equal.

func (Float64s) Sqrt

func (x Float64s) Sqrt() Float64s

Sqrt returns the element-wise square root of x.

func (Float64s) Store

func (x Float64s) Store(s []float64)

Store stores the vector elements into the slice s.

func (Float64s) StorePart

func (x Float64s) StorePart(s []float64) int

StorePart stores a partial vector into the slice s and returns the number actually stored.

func (Float64s) String

func (x Float64s) String() string

String returns a string representation of the vector.

func (Float64s) Sub

func (x Float64s) Sub(y Float64s) Float64s

Sub returns the element-wise difference of x and y.

func (Float64s) ToArch

func (x Float64s) ToArch() any

func (Float64s) ToBits

func (x Float64s) ToBits() Uint64s

ToBits reinterprets the vector bits as an unsigned integer vector.

type Int8s

type Int8s struct {
	// contains filtered or unexported fields
}

Int8s represents a vector of 8-bit signed integers.

func BroadcastInt8s

func BroadcastInt8s(int8) Int8s

BroadcastInt8 fills the elements of a slice with its argument value.

func Int8sFromArch

func Int8sFromArch[T archSimdInt8s](x T) Int8s

func LoadInt8s

func LoadInt8s([]int8) Int8s

LoadInt8 loads a slice of int8 into an Int8s vector.

func LoadInt8sPart

func LoadInt8sPart([]int8) (Int8s, int)

LoadInt8Part loads a partial slice of int8 into an Int8s vector, returning the vector and the number of elements loaded.

Example
package main

import (
	"fmt"
	"simd"
)

func main() {
	// Slice smaller than the full vector length.
	s := []int8{1, 2, 3, 4, 5}

	// Load partial slice.
	v, n := simd.LoadInt8sPart(s)
	fmt.Printf("Loaded %d elements\n", n)

	// Store only the loaded elements.
	out := make([]int8, n)
	v.StorePart(out)
	fmt.Println(out)

}
Output:
Loaded 5 elements
[1 2 3 4 5]

func (Int8s) Abs

func (x Int8s) Abs() Int8s

Abs returns the element-wise absolute value of x.

func (Int8s) Add

func (x Int8s) Add(y Int8s) Int8s

Add returns the element-wise sum of x and y.

Example
package main

import (
	"fmt"
	"simd"
)

func main() {
	// Initialize slice of 64 int8s (max vector size under AVX512).
	in1 := []int8{
		1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	}
	in2 := []int8{
		10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 100, 10, 10, 10, 16,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	}

	// Load slices into vectors.
	v1 := simd.LoadInt8s(in1)
	v2 := simd.LoadInt8s(in2)

	// Add the vectors.
	sum := v1.Add(v2)

	// Store the result back to a slice.
	out := make([]int8, sum.Len())
	sum.Store(out)

	// Print the first 16 elements (minimum vector width across architectures).
	fmt.Println(out[:16])
}
Output:
[11 22 33 44 55 66 77 88 99 110 121 112 23 24 25 32]

func (Int8s) AddSaturated

func (x Int8s) AddSaturated(y Int8s) Int8s

AddSaturated returns the element-wise saturated sum of x and y.

func (Int8s) And

func (x Int8s) And(y Int8s) Int8s

And returns the bitwise AND of x and y.

func (Int8s) AndNot

func (x Int8s) AndNot(y Int8s) Int8s

AndNot returns the bitwise AND NOT of x and y.

func (Int8s) ConvertToUint8

func (x Int8s) ConvertToUint8() Uint8s

ConvertToUint8 converts the vector elements to uint8.

func (Int8s) Equal

func (x Int8s) Equal(y Int8s) Mask8s

Equal returns a mask indicating where x and y are equal.

func (Int8s) Greater

func (x Int8s) Greater(y Int8s) Mask8s

Greater returns a mask indicating where x is greater than y.

func (Int8s) GreaterEqual

func (x Int8s) GreaterEqual(y Int8s) Mask8s

GreaterEqual returns a mask indicating where x is greater than or equal to y.

func (Int8s) IfElse

func (x Int8s) IfElse(mask Mask8s, y Int8s) Int8s

IfElse returns a new vector with elements from x where mask is true, and y where mask is false.

func (Int8s) Len

func (x Int8s) Len() int

Len returns the number of elements in the vector.

func (Int8s) Less

func (x Int8s) Less(y Int8s) Mask8s

Less returns a mask indicating where x is less than y.

func (Int8s) LessEqual

func (x Int8s) LessEqual(y Int8s) Mask8s

LessEqual returns a mask indicating where x is less than or equal to y.

func (Int8s) Masked

func (x Int8s) Masked(mask Mask8s) Int8s

Masked returns a new vector with elements from x where mask is true, and zero elsewhere.

Example
package main

import (
	"fmt"
	"simd"
)

func main() {
	// Load vectors of 64 elements.
	v1 := simd.LoadInt8s([]int8{
		1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	})
	var v2 simd.Int8s // zero value

	// Create a mask where elements in v1 are greater than zero.
	mask := v1.Greater(v2)

	// Keep elements of v1 where the mask is true, zero out elsewhere.
	res := v1.Masked(mask)

	out := make([]int8, res.Len())
	res.Store(out)

	// Print the first 16 elements.
	fmt.Println(out[:16])
}
Output:
[1 0 3 0 5 0 7 0 9 0 11 0 13 0 15 0]

func (Int8s) Max

func (x Int8s) Max(y Int8s) Int8s

Max returns the element-wise maximum of x and y.

func (Int8s) Min

func (x Int8s) Min(y Int8s) Int8s

Min returns the element-wise minimum of x and y.

func (Int8s) Mul

func (x Int8s) Mul(y Int8s) Int8s

Mul returns the element-wise product of x and y.

func (Int8s) Neg

func (x Int8s) Neg() Int8s

Neg returns the element-wise negation of x.

func (Int8s) Not

func (x Int8s) Not() Int8s

Not returns the bitwise NOT of x.

func (Int8s) NotEqual

func (x Int8s) NotEqual(y Int8s) Mask8s

NotEqual returns a mask indicating where x and y are not equal.

func (Int8s) Or

func (x Int8s) Or(y Int8s) Int8s

Or returns the bitwise OR of x and y.

func (Int8s) Store

func (x Int8s) Store(s []int8)

Store stores the vector elements into the slice s.

func (Int8s) StorePart

func (x Int8s) StorePart(s []int8) int

StorePart stores a partial vector into the slice s and returns the number actually stored.

func (Int8s) String

func (x Int8s) String() string

String returns a string representation of the vector.

func (Int8s) Sub

func (x Int8s) Sub(y Int8s) Int8s

Sub returns the element-wise difference of x and y.

func (Int8s) SubSaturated

func (x Int8s) SubSaturated(y Int8s) Int8s

SubSaturated returns the element-wise saturated difference of x and y.

func (Int8s) ToArch

func (x Int8s) ToArch() any

func (Int8s) ToBits

func (x Int8s) ToBits() Uint8s

ToBits reinterprets the vector bits as an unsigned integer vector.

func (Int8s) ToMask

func (x Int8s) ToMask() (to Mask8s)

ToMask returns a mask representation of the vector.

func (Int8s) Xor

func (x Int8s) Xor(y Int8s) Int8s

Xor returns the bitwise XOR of x and y.

type Int16s

type Int16s struct {
	// contains filtered or unexported fields
}

Int16s represents a vector of 16-bit signed integers.

func BroadcastInt16s

func BroadcastInt16s(int16) Int16s

BroadcastInt16 fills the elements of a slice with its argument value.

func Int16sFromArch

func Int16sFromArch[T archSimdInt16s](x T) Int16s

func LoadInt16s

func LoadInt16s([]int16) Int16s

LoadInt16 loads a slice of int16 into an Int16s vector.

func LoadInt16sPart

func LoadInt16sPart([]int16) (Int16s, int)

LoadInt16Part loads a partial slice of int16 into an Int16s vector, returning the vector and the number of elements loaded.

func (Int16s) Abs

func (x Int16s) Abs() Int16s

Abs returns the element-wise absolute value of x.

func (Int16s) Add

func (x Int16s) Add(y Int16s) Int16s

Add returns the element-wise sum of x and y.

func (Int16s) AddSaturated

func (x Int16s) AddSaturated(y Int16s) Int16s

AddSaturated returns the element-wise saturated sum of x and y.

func (Int16s) And

func (x Int16s) And(y Int16s) Int16s

And returns the bitwise AND of x and y.

func (Int16s) AndNot

func (x Int16s) AndNot(y Int16s) Int16s

AndNot returns the bitwise AND NOT of x and y.

func (Int16s) ConvertToUint16

func (x Int16s) ConvertToUint16() Uint16s

ConvertToUint16 converts the vector elements to uint16.

func (Int16s) Equal

func (x Int16s) Equal(y Int16s) Mask16s

Equal returns a mask indicating where x and y are equal.

func (Int16s) Greater

func (x Int16s) Greater(y Int16s) Mask16s

Greater returns a mask indicating where x is greater than y.

func (Int16s) GreaterEqual

func (x Int16s) GreaterEqual(y Int16s) Mask16s

GreaterEqual returns a mask indicating where x is greater than or equal to y.

func (Int16s) IfElse

func (x Int16s) IfElse(mask Mask16s, y Int16s) Int16s

IfElse returns a new vector with elements from x where mask is true, and y where mask is false.

func (Int16s) Len

func (x Int16s) Len() int

Len returns the number of elements in the vector.

func (Int16s) Less

func (x Int16s) Less(y Int16s) Mask16s

Less returns a mask indicating where x is less than y.

func (Int16s) LessEqual

func (x Int16s) LessEqual(y Int16s) Mask16s

LessEqual returns a mask indicating where x is less than or equal to y.

func (Int16s) Masked

func (x Int16s) Masked(mask Mask16s) Int16s

Masked returns a new vector with elements from x where mask is true, and zero elsewhere.

func (Int16s) Max

func (x Int16s) Max(y Int16s) Int16s

Max returns the element-wise maximum of x and y.

func (Int16s) Min

func (x Int16s) Min(y Int16s) Int16s

Min returns the element-wise minimum of x and y.

func (Int16s) Mul

func (x Int16s) Mul(y Int16s) Int16s

Mul returns the element-wise product of x and y.

func (Int16s) Neg

func (x Int16s) Neg() Int16s

Neg returns the element-wise negation of x.

func (Int16s) Not

func (x Int16s) Not() Int16s

Not returns the bitwise NOT of x.

func (Int16s) NotEqual

func (x Int16s) NotEqual(y Int16s) Mask16s

NotEqual returns a mask indicating where x and y are not equal.

func (Int16s) Or

func (x Int16s) Or(y Int16s) Int16s

Or returns the bitwise OR of x and y.

func (Int16s) RotateAllLeft

func (x Int16s) RotateAllLeft(dist uint64) Int16s

RotatesAllLeft rotates all elements left by y bits.

Example
package main

import (
	"fmt"
	"simd"
)

func main() {
	// Int16s on 512-bit vector has 32 elements.
	in := []int16{
		0x00f0, 0x1234, 0, 0, 0, 0, 0, 0x7000,
		0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0,
	}
	v := simd.LoadInt16s(in)

	// Rotate all elements left by 4 bits.
	res := v.RotateAllLeft(4)

	out := make([]int16, res.Len())
	res.Store(out)

	fmt.Printf("%#04x\n", out[:8])
}
Output:
[0x0f00 0x2341 0x0000 0x0000 0x0000 0x0000 0x0000 0x0007]

func (Int16s) RotateAllRight

func (x Int16s) RotateAllRight(dist uint64) Int16s

RotatesAllRight rotates all elements right by y bits.

func (Int16s) ShiftAllLeft

func (x Int16s) ShiftAllLeft(shift uint64) Int16s

ShiftAllLeft shifts all elements left by y bits.

Example
package main

import (
	"fmt"
	"simd"
)

func main() {
	// Int16s on 512-bit vector has 32 elements.
	in := []int16{
		1, 2, 4, 8, 16, 32, 64, 128,
		0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0,
	}
	v := simd.LoadInt16s(in)

	// Shift all elements left by 2 bits.
	res := v.ShiftAllLeft(2)

	out := make([]int16, res.Len())
	res.Store(out)

	// Print the first 8 elements.
	fmt.Println(out[:8])
}
Output:
[4 8 16 32 64 128 256 512]

func (Int16s) ShiftAllRight

func (x Int16s) ShiftAllRight(shift uint64) Int16s

ShiftAllRight shifts all elements right by y bits.

func (Int16s) Store

func (x Int16s) Store(s []int16)

Store stores the vector elements into the slice s.

func (Int16s) StorePart

func (x Int16s) StorePart(s []int16) int

StorePart stores a partial vector into the slice s and returns the number actually stored.

func (Int16s) String

func (x Int16s) String() string

String returns a string representation of the vector.

func (Int16s) Sub

func (x Int16s) Sub(y Int16s) Int16s

Sub returns the element-wise difference of x and y.

func (Int16s) SubSaturated

func (x Int16s) SubSaturated(y Int16s) Int16s

SubSaturated returns the element-wise saturated difference of x and y.

func (Int16s) ToArch

func (x Int16s) ToArch() any

func (Int16s) ToBits

func (x Int16s) ToBits() Uint16s

ToBits reinterprets the vector bits as an unsigned integer vector.

func (Int16s) ToMask

func (x Int16s) ToMask() (to Mask16s)

ToMask returns a mask representation of the vector.

func (Int16s) Xor

func (x Int16s) Xor(y Int16s) Int16s

Xor returns the bitwise XOR of x and y.

type Int32s

type Int32s struct {
	// contains filtered or unexported fields
}

Int32s represents a vector of 32-bit signed integers.

func BroadcastInt32s

func BroadcastInt32s(int32) Int32s

BroadcastInt32 fills the elements of a slice with its argument value.

func Int32sFromArch

func Int32sFromArch[T archSimdInt32s](x T) Int32s

func LoadInt32s

func LoadInt32s([]int32) Int32s

LoadInt32 loads a slice of int32 into an Int32s vector.

func LoadInt32sPart

func LoadInt32sPart([]int32) (Int32s, int)

LoadInt32Part loads a partial slice of int32 into an Int32s vector, returning the vector and the number of elements loaded.

func (Int32s) Abs

func (x Int32s) Abs() Int32s

Abs returns the element-wise absolute value of x.

func (Int32s) Add

func (x Int32s) Add(y Int32s) Int32s

Add returns the element-wise sum of x and y.

func (Int32s) And

func (x Int32s) And(y Int32s) Int32s

And returns the bitwise AND of x and y.

func (Int32s) AndNot

func (x Int32s) AndNot(y Int32s) Int32s

AndNot returns the bitwise AND NOT of x and y.

func (Int32s) ConvertToFloat32

func (x Int32s) ConvertToFloat32() Float32s

ConvertToFloat32 converts the vector elements to float32.

func (Int32s) ConvertToUint32

func (x Int32s) ConvertToUint32() Uint32s

ConvertToUint32 converts the vector elements to uint32.

func (Int32s) Equal

func (x Int32s) Equal(y Int32s) Mask32s

Equal returns a mask indicating where x and y are equal.

func (Int32s) Greater

func (x Int32s) Greater(y Int32s) Mask32s

Greater returns a mask indicating where x is greater than y.

func (Int32s) GreaterEqual

func (x Int32s) GreaterEqual(y Int32s) Mask32s

GreaterEqual returns a mask indicating where x is greater than or equal to y.

func (Int32s) IfElse

func (x Int32s) IfElse(mask Mask32s, y Int32s) Int32s

IfElse returns a new vector with elements from x where mask is true, and y where mask is false.

func (Int32s) Len

func (x Int32s) Len() int

Len returns the number of elements in the vector.

func (Int32s) Less

func (x Int32s) Less(y Int32s) Mask32s

Less returns a mask indicating where x is less than y.

func (Int32s) LessEqual

func (x Int32s) LessEqual(y Int32s) Mask32s

LessEqual returns a mask indicating where x is less than or equal to y.

func (Int32s) Masked

func (x Int32s) Masked(mask Mask32s) Int32s

Masked returns a new vector with elements from x where mask is true, and zero elsewhere.

func (Int32s) Max

func (x Int32s) Max(y Int32s) Int32s

Max returns the element-wise maximum of x and y.

func (Int32s) Min

func (x Int32s) Min(y Int32s) Int32s

Min returns the element-wise minimum of x and y.

func (Int32s) Mul

func (x Int32s) Mul(y Int32s) Int32s

Mul returns the element-wise product of x and y.

func (Int32s) Neg

func (x Int32s) Neg() Int32s

Neg returns the element-wise negation of x.

func (Int32s) Not

func (x Int32s) Not() Int32s

Not returns the bitwise NOT of x.

func (Int32s) NotEqual

func (x Int32s) NotEqual(y Int32s) Mask32s

NotEqual returns a mask indicating where x and y are not equal.

func (Int32s) Or

func (x Int32s) Or(y Int32s) Int32s

Or returns the bitwise OR of x and y.

func (Int32s) RotateAllLeft

func (x Int32s) RotateAllLeft(dist uint64) Int32s

RotatesAllLeft rotates all elements left by y bits.

func (Int32s) RotateAllRight

func (x Int32s) RotateAllRight(dist uint64) Int32s

RotatesAllRight rotates all elements right by y bits.

func (Int32s) ShiftAllLeft

func (x Int32s) ShiftAllLeft(shift uint64) Int32s

ShiftAllLeft shifts all elements left by y bits.

func (Int32s) ShiftAllRight

func (x Int32s) ShiftAllRight(shift uint64) Int32s

ShiftAllRight shifts all elements right by y bits.

func (Int32s) Store

func (x Int32s) Store(s []int32)

Store stores the vector elements into the slice s.

func (Int32s) StorePart

func (x Int32s) StorePart(s []int32) int

StorePart stores a partial vector into the slice s and returns the number actually stored.

func (Int32s) String

func (x Int32s) String() string

String returns a string representation of the vector.

func (Int32s) Sub

func (x Int32s) Sub(y Int32s) Int32s

Sub returns the element-wise difference of x and y.

func (Int32s) ToArch

func (x Int32s) ToArch() any

func (Int32s) ToBits

func (x Int32s) ToBits() Uint32s

ToBits reinterprets the vector bits as an unsigned integer vector.

func (Int32s) ToMask

func (x Int32s) ToMask() (to Mask32s)

ToMask returns a mask representation of the vector.

func (Int32s) Xor

func (x Int32s) Xor(y Int32s) Int32s

Xor returns the bitwise XOR of x and y.

type Int64s

type Int64s struct {
	// contains filtered or unexported fields
}

Int64s represents a vector of 64-bit signed integers.

func BroadcastInt64s

func BroadcastInt64s(int64) Int64s

BroadcastInt64 fills the elements of a slice with its argument value.

func Int64sFromArch

func Int64sFromArch[T archSimdInt64s](x T) Int64s

func LoadInt64s

func LoadInt64s([]int64) Int64s

LoadInt64 loads a slice of int64 into an Int64s vector.

func LoadInt64sPart

func LoadInt64sPart([]int64) (Int64s, int)

LoadInt64Part loads a partial slice of int64 into an Int64s vector, returning the vector and the number of elements loaded.

func (Int64s) Add

func (x Int64s) Add(y Int64s) Int64s

Add returns the element-wise sum of x and y.

func (Int64s) And

func (x Int64s) And(y Int64s) Int64s

And returns the bitwise AND of x and y.

func (Int64s) AndNot

func (x Int64s) AndNot(y Int64s) Int64s

AndNot returns the bitwise AND NOT of x and y.

func (Int64s) ConvertToUint64

func (x Int64s) ConvertToUint64() Uint64s

ConvertToUint64 converts the vector elements to uint64.

func (Int64s) Equal

func (x Int64s) Equal(y Int64s) Mask64s

Equal returns a mask indicating where x and y are equal.

func (Int64s) Greater

func (x Int64s) Greater(y Int64s) Mask64s

Greater returns a mask indicating where x is greater than y.

func (Int64s) GreaterEqual

func (x Int64s) GreaterEqual(y Int64s) Mask64s

GreaterEqual returns a mask indicating where x is greater than or equal to y.

func (Int64s) IfElse

func (x Int64s) IfElse(mask Mask64s, y Int64s) Int64s

IfElse returns a new vector with elements from x where mask is true, and y where mask is false.

func (Int64s) Len

func (x Int64s) Len() int

Len returns the number of elements in the vector.

func (Int64s) Less

func (x Int64s) Less(y Int64s) Mask64s

Less returns a mask indicating where x is less than y.

func (Int64s) LessEqual

func (x Int64s) LessEqual(y Int64s) Mask64s

LessEqual returns a mask indicating where x is less than or equal to y.

func (Int64s) Masked

func (x Int64s) Masked(mask Mask64s) Int64s

Masked returns a new vector with elements from x where mask is true, and zero elsewhere.

func (Int64s) Neg

func (x Int64s) Neg() Int64s

Neg returns the element-wise negation of x.

func (Int64s) Not

func (x Int64s) Not() Int64s

Not returns the bitwise NOT of x.

func (Int64s) NotEqual

func (x Int64s) NotEqual(y Int64s) Mask64s

NotEqual returns a mask indicating where x and y are not equal.

func (Int64s) Or

func (x Int64s) Or(y Int64s) Int64s

Or returns the bitwise OR of x and y.

func (Int64s) RotateAllLeft

func (x Int64s) RotateAllLeft(dist uint64) Int64s

RotatesAllLeft rotates all elements left by y bits.

func (Int64s) RotateAllRight

func (x Int64s) RotateAllRight(dist uint64) Int64s

RotatesAllRight rotates all elements right by y bits.

func (Int64s) ShiftAllLeft

func (x Int64s) ShiftAllLeft(shift uint64) Int64s

ShiftAllLeft shifts all elements left by y bits.

func (Int64s) Store

func (x Int64s) Store(s []int64)

Store stores the vector elements into the slice s.

func (Int64s) StorePart

func (x Int64s) StorePart(s []int64) int

StorePart stores a partial vector into the slice s and returns the number actually stored.

func (Int64s) String

func (x Int64s) String() string

String returns a string representation of the vector.

func (Int64s) Sub

func (x Int64s) Sub(y Int64s) Int64s

Sub returns the element-wise difference of x and y.

func (Int64s) ToArch

func (x Int64s) ToArch() any

func (Int64s) ToBits

func (x Int64s) ToBits() Uint64s

ToBits reinterprets the vector bits as an unsigned integer vector.

func (Int64s) ToMask

func (x Int64s) ToMask() (to Mask64s)

ToMask returns a mask representation of the vector.

func (Int64s) Xor

func (x Int64s) Xor(y Int64s) Int64s

Xor returns the bitwise XOR of x and y.

type Mask8s

type Mask8s struct {
	// contains filtered or unexported fields
}

Mask8s represents a boolean mask for Int8s/Uint8s vectors.

func Mask8sFromArch

func Mask8sFromArch[T archSimdMask8s](x T) Mask8s

func (Mask8s) And

func (x Mask8s) And(y Mask8s) Mask8s

And returns the bitwise AND of x and y.

func (Mask8s) Or

func (x Mask8s) Or(y Mask8s) Mask8s

Or returns the bitwise OR of x and y.

func (Mask8s) String

func (x Mask8s) String() string

String returns a string representation of the vector.

func (Mask8s) ToArch

func (x Mask8s) ToArch() any

func (Mask8s) ToInt8s

func (x Mask8s) ToInt8s() (to Int8s)

ToInt8s converts the mask to an Int8s vector.

type Mask16s

type Mask16s struct {
	// contains filtered or unexported fields
}

Mask16s represents a boolean mask for Int16s/Uint16s vectors.

func Mask16sFromArch

func Mask16sFromArch[T archSimdMask16s](x T) Mask16s

func (Mask16s) And

func (x Mask16s) And(y Mask16s) Mask16s

And returns the bitwise AND of x and y.

func (Mask16s) Or

func (x Mask16s) Or(y Mask16s) Mask16s

Or returns the bitwise OR of x and y.

func (Mask16s) String

func (x Mask16s) String() string

String returns a string representation of the vector.

func (Mask16s) ToArch

func (x Mask16s) ToArch() any

func (Mask16s) ToInt16s

func (x Mask16s) ToInt16s() (to Int16s)

ToInt16s converts the mask to an Int16s vector.

type Mask32s

type Mask32s struct {
	// contains filtered or unexported fields
}

Mask32s represents a boolean mask for Int32s/Uint32s vectors.

func Mask32sFromArch

func Mask32sFromArch[T archSimdMask32s](x T) Mask32s

func (Mask32s) And

func (x Mask32s) And(y Mask32s) Mask32s

And returns the bitwise AND of x and y.

func (Mask32s) Or

func (x Mask32s) Or(y Mask32s) Mask32s

Or returns the bitwise OR of x and y.

func (Mask32s) String

func (x Mask32s) String() string

String returns a string representation of the vector.

func (Mask32s) ToArch

func (x Mask32s) ToArch() any

func (Mask32s) ToInt32s

func (x Mask32s) ToInt32s() (to Int32s)

ToInt32s converts the mask to an Int32s vector.

type Mask64s

type Mask64s struct {
	// contains filtered or unexported fields
}

Mask64s represents a boolean mask for Int64s/Uint64s vectors.

func Mask64sFromArch

func Mask64sFromArch[T archSimdMask64s](x T) Mask64s

func (Mask64s) And

func (x Mask64s) And(y Mask64s) Mask64s

And returns the bitwise AND of x and y.

func (Mask64s) Or

func (x Mask64s) Or(y Mask64s) Mask64s

Or returns the bitwise OR of x and y.

func (Mask64s) String

func (x Mask64s) String() string

String returns a string representation of the vector.

func (Mask64s) ToArch

func (x Mask64s) ToArch() any

func (Mask64s) ToInt64s

func (x Mask64s) ToInt64s() (to Int64s)

ToInt64s converts the mask to an Int64s vector.

type Uint8s

type Uint8s struct {
	// contains filtered or unexported fields
}

Uint8s represents a vector of 8-bit unsigned integers.

func BroadcastUint8s

func BroadcastUint8s(uint8) Uint8s

BroadcastUint8 fills the elements of a slice with its argument value.

func LoadUint8s

func LoadUint8s([]uint8) Uint8s

LoadUint8 loads a slice of uint8 into an Uint8s vector.

func LoadUint8sPart

func LoadUint8sPart([]uint8) (Uint8s, int)

LoadUint8Part loads a partial slice of uint8 into an Uint8s vector, returning the vector and the number of elements loaded.

func Uint8sFromArch

func Uint8sFromArch[T archSimdUint8s](x T) Uint8s

func (Uint8s) Add

func (x Uint8s) Add(y Uint8s) Uint8s

Add returns the element-wise sum of x and y.

func (Uint8s) AddSaturated

func (x Uint8s) AddSaturated(y Uint8s) Uint8s

AddSaturated returns the element-wise saturated sum of x and y.

func (Uint8s) And

func (x Uint8s) And(y Uint8s) Uint8s

And returns the bitwise AND of x and y.

func (Uint8s) AndNot

func (x Uint8s) AndNot(y Uint8s) Uint8s

AndNot returns the bitwise AND NOT of x and y.

func (Uint8s) Average

func (x Uint8s) Average(y Uint8s) Uint8s

Average returns the element-wise average of x and y.

func (Uint8s) BitsToInt8

func (x Uint8s) BitsToInt8() Int8s

BitsToInt8 reinterprets the vector bits as an Int8s vector.

func (Uint8s) ConvertToInt8

func (x Uint8s) ConvertToInt8() Int8s

ConvertToInt8 converts the vector elements to int8.

func (Uint8s) Equal

func (x Uint8s) Equal(y Uint8s) Mask8s

Equal returns a mask indicating where x and y are equal.

func (Uint8s) IfElse

func (x Uint8s) IfElse(mask Mask8s, y Uint8s) Uint8s

IfElse returns a new vector with elements from x where mask is true, and y where mask is false.

func (Uint8s) Len

func (x Uint8s) Len() int

Len returns the number of elements in the vector.

func (Uint8s) Masked

func (x Uint8s) Masked(mask Mask8s) Uint8s

Masked returns a new vector with elements from x where mask is true, and zero elsewhere.

func (Uint8s) Max

func (x Uint8s) Max(y Uint8s) Uint8s

Max returns the element-wise maximum of x and y.

func (Uint8s) Min

func (x Uint8s) Min(y Uint8s) Uint8s

Min returns the element-wise minimum of x and y.

func (Uint8s) Mul

func (x Uint8s) Mul(y Uint8s) Uint8s

Mul returns the element-wise product of x and y.

func (Uint8s) Not

func (x Uint8s) Not() Uint8s

Not returns the bitwise NOT of x.

func (Uint8s) NotEqual

func (x Uint8s) NotEqual(y Uint8s) Mask8s

NotEqual returns a mask indicating where x and y are not equal.

func (Uint8s) Or

func (x Uint8s) Or(y Uint8s) Uint8s

Or returns the bitwise OR of x and y.

func (Uint8s) ReshapeToUint16s

func (x Uint8s) ReshapeToUint16s() Uint16s

ReshapeToUint16s reinterprets the vector bits as a Uint16s vector.

func (Uint8s) ReshapeToUint32s

func (x Uint8s) ReshapeToUint32s() Uint32s

ReshapeToUint32s reinterprets the vector bits as a Uint32s vector.

func (Uint8s) ReshapeToUint64s

func (x Uint8s) ReshapeToUint64s() Uint64s

ReshapeToUint64s reinterprets the vector bits as a Uint64s vector.

func (Uint8s) Store

func (x Uint8s) Store(s []uint8)

Store stores the vector elements into the slice s.

func (Uint8s) StorePart

func (x Uint8s) StorePart(s []uint8) int

StorePart stores a partial vector into the slice s and returns the number actually stored.

func (Uint8s) String

func (x Uint8s) String() string

String returns a string representation of the vector.

func (Uint8s) Sub

func (x Uint8s) Sub(y Uint8s) Uint8s

Sub returns the element-wise difference of x and y.

func (Uint8s) SubSaturated

func (x Uint8s) SubSaturated(y Uint8s) Uint8s

SubSaturated returns the element-wise saturated difference of x and y.

func (Uint8s) ToArch

func (x Uint8s) ToArch() any

func (Uint8s) Xor

func (x Uint8s) Xor(y Uint8s) Uint8s

Xor returns the bitwise XOR of x and y.

type Uint16s

type Uint16s struct {
	// contains filtered or unexported fields
}

Uint16s represents a vector of 16-bit unsigned integers.

func BroadcastUint16s

func BroadcastUint16s(uint16) Uint16s

BroadcastUint16 fills the elements of a slice with its argument value.

func LoadUint16s

func LoadUint16s([]uint16) Uint16s

LoadUint16 loads a slice of uint16 into an Uint16s vector.

func LoadUint16sPart

func LoadUint16sPart([]uint16) (Uint16s, int)

LoadUint16Part loads a partial slice of uint16 into an Uint16s vector, returning the vector and the number of elements loaded.

func Uint16sFromArch

func Uint16sFromArch[T archSimdUint16s](x T) Uint16s

func (Uint16s) Add

func (x Uint16s) Add(y Uint16s) Uint16s

Add returns the element-wise sum of x and y.

func (Uint16s) AddSaturated

func (x Uint16s) AddSaturated(y Uint16s) Uint16s

AddSaturated returns the element-wise saturated sum of x and y.

func (Uint16s) And

func (x Uint16s) And(y Uint16s) Uint16s

And returns the bitwise AND of x and y.

func (Uint16s) AndNot

func (x Uint16s) AndNot(y Uint16s) Uint16s

AndNot returns the bitwise AND NOT of x and y.

func (Uint16s) Average

func (x Uint16s) Average(y Uint16s) Uint16s

Average returns the element-wise average of x and y.

func (Uint16s) BitsToInt16

func (x Uint16s) BitsToInt16() Int16s

BitsToInt16 reinterprets the vector bits as an Int16s vector.

func (Uint16s) ConvertToInt16

func (x Uint16s) ConvertToInt16() Int16s

ConvertToInt16 converts the vector elements to int16.

func (Uint16s) Equal

func (x Uint16s) Equal(y Uint16s) Mask16s

Equal returns a mask indicating where x and y are equal.

func (Uint16s) Greater

func (x Uint16s) Greater(y Uint16s) Mask16s

Greater returns a mask indicating where x is greater than y.

func (Uint16s) GreaterEqual

func (x Uint16s) GreaterEqual(y Uint16s) Mask16s

GreaterEqual returns a mask indicating where x is greater than or equal to y.

func (Uint16s) IfElse

func (x Uint16s) IfElse(mask Mask16s, y Uint16s) Uint16s

IfElse returns a new vector with elements from x where mask is true, and y where mask is false.

func (Uint16s) Len

func (x Uint16s) Len() int

Len returns the number of elements in the vector.

func (Uint16s) Less

func (x Uint16s) Less(y Uint16s) Mask16s

Less returns a mask indicating where x is less than y.

func (Uint16s) LessEqual

func (x Uint16s) LessEqual(y Uint16s) Mask16s

LessEqual returns a mask indicating where x is less than or equal to y.

func (Uint16s) Masked

func (x Uint16s) Masked(mask Mask16s) Uint16s

Masked returns a new vector with elements from x where mask is true, and zero elsewhere.

func (Uint16s) Max

func (x Uint16s) Max(y Uint16s) Uint16s

Max returns the element-wise maximum of x and y.

func (Uint16s) Min

func (x Uint16s) Min(y Uint16s) Uint16s

Min returns the element-wise minimum of x and y.

func (Uint16s) Mul

func (x Uint16s) Mul(y Uint16s) Uint16s

Mul returns the element-wise product of x and y.

func (Uint16s) Not

func (x Uint16s) Not() Uint16s

Not returns the bitwise NOT of x.

func (Uint16s) NotEqual

func (x Uint16s) NotEqual(y Uint16s) Mask16s

NotEqual returns a mask indicating where x and y are not equal.

func (Uint16s) Or

func (x Uint16s) Or(y Uint16s) Uint16s

Or returns the bitwise OR of x and y.

func (Uint16s) ReshapeToUint8s

func (x Uint16s) ReshapeToUint8s() Uint8s

ReshapeToUint8s reinterprets the vector bits as a Uint8s vector.

func (Uint16s) ReshapeToUint32s

func (x Uint16s) ReshapeToUint32s() Uint32s

ReshapeToUint32s reinterprets the vector bits as a Uint32s vector.

func (Uint16s) ReshapeToUint64s

func (x Uint16s) ReshapeToUint64s() Uint64s

ReshapeToUint64s reinterprets the vector bits as a Uint64s vector.

func (Uint16s) RotateAllLeft

func (x Uint16s) RotateAllLeft(dist uint64) Uint16s

RotatesAllLeft rotates all elements left by y bits.

func (Uint16s) RotateAllRight

func (x Uint16s) RotateAllRight(dist uint64) Uint16s

RotatesAllRight rotates all elements right by y bits.

func (Uint16s) ShiftAllLeft

func (x Uint16s) ShiftAllLeft(shift uint64) Uint16s

ShiftAllLeft shifts all elements left by y bits.

func (Uint16s) ShiftAllRight

func (x Uint16s) ShiftAllRight(shift uint64) Uint16s

ShiftAllRight shifts all elements right by y bits.

func (Uint16s) Store

func (x Uint16s) Store(s []uint16)

Store stores the vector elements into the slice s.

func (Uint16s) StorePart

func (x Uint16s) StorePart(s []uint16) int

StorePart stores a partial vector into the slice s and returns the number actually stored.

func (Uint16s) String

func (x Uint16s) String() string

String returns a string representation of the vector.

func (Uint16s) Sub

func (x Uint16s) Sub(y Uint16s) Uint16s

Sub returns the element-wise difference of x and y.

func (Uint16s) SubSaturated

func (x Uint16s) SubSaturated(y Uint16s) Uint16s

SubSaturated returns the element-wise saturated difference of x and y.

func (Uint16s) ToArch

func (x Uint16s) ToArch() any

func (Uint16s) Xor

func (x Uint16s) Xor(y Uint16s) Uint16s

Xor returns the bitwise XOR of x and y.

type Uint32s

type Uint32s struct {
	// contains filtered or unexported fields
}

Uint32s represents a vector of 32-bit unsigned integers.

func BroadcastUint32s

func BroadcastUint32s(uint32) Uint32s

BroadcastUint32 fills the elements of a slice with its argument value.

func LoadUint32s

func LoadUint32s([]uint32) Uint32s

LoadUint32 loads a slice of uint32 into an Uint32s vector.

func LoadUint32sPart

func LoadUint32sPart([]uint32) (Uint32s, int)

LoadUint32Part loads a partial slice of uint32 into an Uint32s vector, returning the vector and the number of elements loaded.

func Uint32sFromArch

func Uint32sFromArch[T archSimdUint32s](x T) Uint32s

func (Uint32s) Add

func (x Uint32s) Add(y Uint32s) Uint32s

Add returns the element-wise sum of x and y.

func (Uint32s) And

func (x Uint32s) And(y Uint32s) Uint32s

And returns the bitwise AND of x and y.

func (Uint32s) AndNot

func (x Uint32s) AndNot(y Uint32s) Uint32s

AndNot returns the bitwise AND NOT of x and y.

func (Uint32s) BitsToFloat32

func (x Uint32s) BitsToFloat32() Float32s

BitsToFloat32 reinterprets the vector bits as a Float32s vector.

func (Uint32s) BitsToInt32

func (x Uint32s) BitsToInt32() Int32s

BitsToInt32 reinterprets the vector bits as an Int32s vector.

func (Uint32s) ConvertToInt32

func (x Uint32s) ConvertToInt32() Int32s

ConvertToInt32 converts the vector elements to int32.

func (Uint32s) Equal

func (x Uint32s) Equal(y Uint32s) Mask32s

Equal returns a mask indicating where x and y are equal.

func (Uint32s) Greater

func (x Uint32s) Greater(y Uint32s) Mask32s

Greater returns a mask indicating where x is greater than y.

func (Uint32s) GreaterEqual

func (x Uint32s) GreaterEqual(y Uint32s) Mask32s

GreaterEqual returns a mask indicating where x is greater than or equal to y.

func (Uint32s) IfElse

func (x Uint32s) IfElse(mask Mask32s, y Uint32s) Uint32s

IfElse returns a new vector with elements from x where mask is true, and y where mask is false.

func (Uint32s) Len

func (x Uint32s) Len() int

Len returns the number of elements in the vector.

func (Uint32s) Less

func (x Uint32s) Less(y Uint32s) Mask32s

Less returns a mask indicating where x is less than y.

func (Uint32s) LessEqual

func (x Uint32s) LessEqual(y Uint32s) Mask32s

LessEqual returns a mask indicating where x is less than or equal to y.

func (Uint32s) Masked

func (x Uint32s) Masked(mask Mask32s) Uint32s

Masked returns a new vector with elements from x where mask is true, and zero elsewhere.

func (Uint32s) Max

func (x Uint32s) Max(y Uint32s) Uint32s

Max returns the element-wise maximum of x and y.

func (Uint32s) Min

func (x Uint32s) Min(y Uint32s) Uint32s

Min returns the element-wise minimum of x and y.

func (Uint32s) Mul

func (x Uint32s) Mul(y Uint32s) Uint32s

Mul returns the element-wise product of x and y.

func (Uint32s) Not

func (x Uint32s) Not() Uint32s

Not returns the bitwise NOT of x.

func (Uint32s) NotEqual

func (x Uint32s) NotEqual(y Uint32s) Mask32s

NotEqual returns a mask indicating where x and y are not equal.

func (Uint32s) Or

func (x Uint32s) Or(y Uint32s) Uint32s

Or returns the bitwise OR of x and y.

func (Uint32s) ReshapeToUint8s

func (x Uint32s) ReshapeToUint8s() Uint8s

ReshapeToUint8s reinterprets the vector bits as a Uint8s vector.

func (Uint32s) ReshapeToUint16s

func (x Uint32s) ReshapeToUint16s() Uint16s

ReshapeToUint16s reinterprets the vector bits as a Uint16s vector.

func (Uint32s) ReshapeToUint64s

func (x Uint32s) ReshapeToUint64s() Uint64s

ReshapeToUint64s reinterprets the vector bits as a Uint64s vector.

func (Uint32s) RotateAllLeft

func (x Uint32s) RotateAllLeft(dist uint64) Uint32s

RotatesAllLeft rotates all elements left by y bits.

func (Uint32s) RotateAllRight

func (x Uint32s) RotateAllRight(dist uint64) Uint32s

RotatesAllRight rotates all elements right by y bits.

func (Uint32s) ShiftAllLeft

func (x Uint32s) ShiftAllLeft(shift uint64) Uint32s

ShiftAllLeft shifts all elements left by y bits.

func (Uint32s) ShiftAllRight

func (x Uint32s) ShiftAllRight(shift uint64) Uint32s

ShiftAllRight shifts all elements right by y bits.

func (Uint32s) Store

func (x Uint32s) Store(s []uint32)

Store stores the vector elements into the slice s.

func (Uint32s) StorePart

func (x Uint32s) StorePart(s []uint32) int

StorePart stores a partial vector into the slice s and returns the number actually stored.

func (Uint32s) String

func (x Uint32s) String() string

String returns a string representation of the vector.

func (Uint32s) Sub

func (x Uint32s) Sub(y Uint32s) Uint32s

Sub returns the element-wise difference of x and y.

func (Uint32s) ToArch

func (x Uint32s) ToArch() any

func (Uint32s) Xor

func (x Uint32s) Xor(y Uint32s) Uint32s

Xor returns the bitwise XOR of x and y.

type Uint64s

type Uint64s struct {
	// contains filtered or unexported fields
}

Uint64s represents a vector of 64-bit unsigned integers.

func BroadcastUint64s

func BroadcastUint64s(uint64) Uint64s

BroadcastUint64 fills the elements of a slice with its argument value.

func LoadUint64s

func LoadUint64s([]uint64) Uint64s

LoadUint64 loads a slice of uint64 into an Uint64s vector.

func LoadUint64sPart

func LoadUint64sPart([]uint64) (Uint64s, int)

LoadUint64Part loads a partial slice of uint64 into an Uint64s vector, returning the vector and the number of elements loaded.

func Uint64sFromArch

func Uint64sFromArch[T archSimdUint64s](x T) Uint64s

func (Uint64s) Add

func (x Uint64s) Add(y Uint64s) Uint64s

Add returns the element-wise sum of x and y.

func (Uint64s) And

func (x Uint64s) And(y Uint64s) Uint64s

And returns the bitwise AND of x and y.

func (Uint64s) AndNot

func (x Uint64s) AndNot(y Uint64s) Uint64s

AndNot returns the bitwise AND NOT of x and y.

func (Uint64s) BitsToFloat64

func (x Uint64s) BitsToFloat64() Float64s

BitsToFloat64 reinterprets the vector bits as a Float64s vector.

func (Uint64s) BitsToInt64

func (x Uint64s) BitsToInt64() Int64s

BitsToInt64 reinterprets the vector bits as an Int64s vector.

func (Uint64s) CarrylessMultiplyEven

func (x Uint64s) CarrylessMultiplyEven(y Uint64s) Uint64s

CarrylessMultiplyOdd computes the carryless multiplications of selected even indexed elements of x and y. Each product is 128 bits wide and fills the corresponding even-odd pairs in the result.

A carryless multiplication uses bitwise XOR instead of add-with-carry, for example (in base two):

11 * 11 = 11 * (10 ^ 1) = (11 * 10) ^ (11 * 1) = 110 ^ 11 = 101

This also models multiplication of polynomials with coefficients from GF(2) -- 11 * 11 models (x+1)*(x+1) = x**2 + (1^1)x + 1 = x**2 + 0x + 1 = x**2 + 1 modeled by 101. (Note that "+" adds polynomial terms, but coefficients "add" with XOR.)"

func (Uint64s) CarrylessMultiplyOdd

func (x Uint64s) CarrylessMultiplyOdd(y Uint64s) Uint64s

CarrylessMultiplyOdd computes the carryless multiplications of selected odd indexed elements of x and y. Each product is 128 bits wide and fills the corresponding even-odd pairs in the result.

A carryless multiplication uses bitwise XOR instead of add-with-carry, for example (in base two):

11 * 11 = 11 * (10 ^ 1) = (11 * 10) ^ (11 * 1) = 110 ^ 11 = 101

This also models multiplication of polynomials with coefficients from GF(2) -- 11 * 11 models (x+1)*(x+1) = x**2 + (1^1)x + 1 = x**2 + 0x + 1 = x**2 + 1 modeled by 101. (Note that "+" adds polynomial terms, but coefficients "add" with XOR.)"

func (Uint64s) ConvertToInt64

func (x Uint64s) ConvertToInt64() Int64s

ConvertToInt64 converts the vector elements to int64.

func (Uint64s) Equal

func (x Uint64s) Equal(y Uint64s) Mask64s

Equal returns a mask indicating where x and y are equal.

func (Uint64s) Greater

func (x Uint64s) Greater(y Uint64s) Mask64s

Greater returns a mask indicating where x is greater than y.

func (Uint64s) GreaterEqual

func (x Uint64s) GreaterEqual(y Uint64s) Mask64s

GreaterEqual returns a mask indicating where x is greater than or equal to y.

func (Uint64s) IfElse

func (x Uint64s) IfElse(mask Mask64s, y Uint64s) Uint64s

IfElse returns a new vector with elements from x where mask is true, and y where mask is false.

func (Uint64s) Len

func (x Uint64s) Len() int

Len returns the number of elements in the vector.

func (Uint64s) Less

func (x Uint64s) Less(y Uint64s) Mask64s

Less returns a mask indicating where x is less than y.

func (Uint64s) LessEqual

func (x Uint64s) LessEqual(y Uint64s) Mask64s

LessEqual returns a mask indicating where x is less than or equal to y.

func (Uint64s) Masked

func (x Uint64s) Masked(mask Mask64s) Uint64s

Masked returns a new vector with elements from x where mask is true, and zero elsewhere.

func (Uint64s) Not

func (x Uint64s) Not() Uint64s

Not returns the bitwise NOT of x.

func (Uint64s) NotEqual

func (x Uint64s) NotEqual(y Uint64s) Mask64s

NotEqual returns a mask indicating where x and y are not equal.

func (Uint64s) Or

func (x Uint64s) Or(y Uint64s) Uint64s

Or returns the bitwise OR of x and y.

func (Uint64s) ReshapeToUint8s

func (x Uint64s) ReshapeToUint8s() Uint8s

ReshapeToUint8s reinterprets the vector bits as a Uint8s vector.

func (Uint64s) ReshapeToUint16s

func (x Uint64s) ReshapeToUint16s() Uint16s

ReshapeToUint16s reinterprets the vector bits as a Uint16s vector.

func (Uint64s) ReshapeToUint32s

func (x Uint64s) ReshapeToUint32s() Uint32s

ReshapeToUint32s reinterprets the vector bits as a Uint32s vector.

func (Uint64s) RotateAllLeft

func (x Uint64s) RotateAllLeft(dist uint64) Uint64s

RotatesAllLeft rotates all elements left by y bits.

func (Uint64s) RotateAllRight

func (x Uint64s) RotateAllRight(dist uint64) Uint64s

RotatesAllRight rotates all elements right by y bits.

func (Uint64s) ShiftAllLeft

func (x Uint64s) ShiftAllLeft(shift uint64) Uint64s

ShiftAllLeft shifts all elements left by y bits.

func (Uint64s) ShiftAllRight

func (x Uint64s) ShiftAllRight(shift uint64) Uint64s

ShiftAllRight shifts all elements right by y bits.

func (Uint64s) Store

func (x Uint64s) Store(s []uint64)

Store stores the vector elements into the slice s.

func (Uint64s) StorePart

func (x Uint64s) StorePart(s []uint64) int

StorePart stores a partial vector into the slice s and returns the number actually stored.

func (Uint64s) String

func (x Uint64s) String() string

String returns a string representation of the vector.

func (Uint64s) Sub

func (x Uint64s) Sub(y Uint64s) Uint64s

Sub returns the element-wise difference of x and y.

func (Uint64s) ToArch

func (x Uint64s) ToArch() any

func (Uint64s) Xor

func (x Uint64s) Xor(y Uint64s) Uint64s

Xor returns the bitwise XOR of x and y.

Notes

Bugs

  • Calls won't work, and there may be other bugs.

  • SIMD-dependent var initializers don't work.

  • Modified names may appear in stack traces and debugging.

Directories

Path Synopsis
Package archsimd provides access to architecture-specific SIMD operations.
Package archsimd provides access to architecture-specific SIMD operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL