moarray

package
v1.2.3-hotfix-20240916 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T types.RealNumbers](v []T) (res []T, err error)

func Add

func Add[T types.RealNumbers](v1, v2 []T) ([]T, error)

func Cast

func Cast[I types.RealNumbers, O types.RealNumbers](in []I) (out []O, err error)

func Compare

func Compare[T types.RealNumbers](v1, v2 []T) int

Compare returns an integer comparing two arrays/vectors lexicographically. TODO: this function might not be correct. we need to compare using tolerance for float values. TODO: need to check if we need len(v1)==len(v2) check.

func CosineDistance

func CosineDistance[T types.RealNumbers](v1, v2 []T) (float64, error)

func CosineSimilarity

func CosineSimilarity[T types.RealNumbers](v1, v2 []T) (float64, error)

func Divide

func Divide[T types.RealNumbers](v1, v2 []T) ([]T, error)

func InnerProduct

func InnerProduct[T types.RealNumbers](v1, v2 []T) (float64, error)

func L1Norm

func L1Norm[T types.RealNumbers](v []T) (float64, error)

L1Norm returns l1 distance to origin.

func L2Distance

func L2Distance[T types.RealNumbers](v1, v2 []T) (float64, error)

func L2Norm

func L2Norm[T types.RealNumbers](v []T) (float64, error)

L2Norm returns l2 distance to origin.

func Multiply

func Multiply[T types.RealNumbers](v1, v2 []T) ([]T, error)

func NormalizeGonumVector added in v1.1.1

func NormalizeGonumVector(vector *mat.VecDense)

NormalizeGonumVector normalizes a vector in place. Note that this function is used by the kmeans algorithm. Here, if we get a zero vector, we do not normalize it and return it directly. This is because the zero vector is a valid vector in the kmeans algorithm.

func NormalizeGonumVectors added in v1.1.1

func NormalizeGonumVectors(vectors []*mat.VecDense)

func NormalizeL2

func NormalizeL2[T types.RealNumbers](v1 []T) ([]T, error)

func ScalarOp added in v1.2.0

func ScalarOp[T types.RealNumbers](v []T, operation string, scalar float64) ([]T, error)

func Sqrt

func Sqrt[T types.RealNumbers](v []T) (res []float64, err error)

func SubArrayFromLeft added in v1.2.0

func SubArrayFromLeft[T types.RealNumbers](s []T, offset int64) []T

SubArrayFromLeft Slice from left to right, starting from 0

func SubArrayFromLeftWithLength added in v1.2.0

func SubArrayFromLeftWithLength[T types.RealNumbers](s []T, offset int64, length int64) []T

SubArrayFromLeftWithLength Cut the slice with length from left to right, starting from 0

func SubArrayFromRight added in v1.2.0

func SubArrayFromRight[T types.RealNumbers](s []T, offset int64) []T

SubArrayFromRight Cut slices from right to left, starting from 1

func SubArrayFromRightWithLength added in v1.2.0

func SubArrayFromRightWithLength[T types.RealNumbers](s []T, offset int64, length int64) []T

SubArrayFromRightWithLength From right to left, cut the slice with length from 1

func Subtract

func Subtract[T types.RealNumbers](v1, v2 []T) ([]T, error)

func Summation

func Summation[T types.RealNumbers](v []T) (float64, error)

func ToGonumVector

func ToGonumVector[T types.RealNumbers](arr1 []T) *mat.VecDense

func ToGonumVectors

func ToGonumVectors[T types.RealNumbers](arrays ...[]T) (res []*mat.VecDense, err error)

func ToMoArray

func ToMoArray[T types.RealNumbers](vec *mat.VecDense) (arr []T, err error)

func ToMoArrays

func ToMoArrays[T types.RealNumbers](vecs []*mat.VecDense) ([][]T, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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