gosimd

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 3 Imported by: 0

README

go get github.com/cartersusi/gosimd

Usage

main.go

package main

import (
	"fmt"
	"math/rand"

	simd "github.com/cartersusi/gosimd"
)

func main() {
	n := 200000
	v1 := make([]float32, n)
	v2 := make([]float32, n)

	for i := 0; i < n; i++ {
		v1[i] = rand.Float32()
		v2[i] = rand.Float32()
	}

	var res float32
	simd.DotProduct(v1, v2, res)
	
	fmt.Println(res)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DotProduct

func DotProduct(left, right []float32, result *float32)

DotProduct calculates the dot product of two vectors using NEON or AVX SIMD instructions if supported, otherwise it falls back to the standard implementation.

Parameters:

  • left: the first vector
  • right: the second vector
  • result: the initial value of the result

Returns:

  • the dot product of the two vectors

func Supported added in v0.0.4

func Supported() bool

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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