func DotF32(a, b []float32) float64 Both slices must have the same length.
Dot products cover float64, float32, int8, and uint8.
package main
import (
"fmt"
nk "github.com/ashvardanian/NumKong/golang"
)
func main() {
a64 := []float64{1, 2, 3}
b64 := []float64{4, 5, 6}
fmt.Println(nk.DotF64(a64, b64))
a32 := []float32{1, 2, 3}
b32 := []float32{4, 5, 6}
fmt.Println(nk.DotF32(a32, b32)) // widened to float64
a8 := []int8{1, 2, 3, 4}
b8 := []int8{4, 3, 2, 1}
fmt.Println(nk.DotI8(a8, b8)) // widened to int32
au := []uint8{1, 2, 3, 4}
bu := []uint8{4, 3, 2, 1}
fmt.Println(nk.DotU8(au, bu)) // widened to uint32
}DotF32 returns float64. DotI8 returns int32. DotU8 returns uint32.
Those widened outputs are deliberate.
DotF32DotF32 computes the dot product of two float32 vectors.DotF64DotF64 computes the dot product of two float64 vectors.DotI8DotI8 computes the dot product of two int8 vectors.DotU8DotU8 computes the dot product of two uint8 vectors.