distance

package
v2.5.5 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// L2 represents the Euclidean distance
	L2 = "L2"
	// IP represents the inner product distance
	IP = "IP"
	// COSINE represents the cosine distance
	COSINE = "COSINE"
)

*

  • Delete in #25663 Remove calc_distance
  • Add back partially as clustering feature needs to calculate distance between search vector and clustering center

Variables

View Source
var (
	L2Impl     func(a []float32, b []float32) float32 = L2ImplPure
	IPImpl     func(a []float32, b []float32) float32 = IPImplPure
	CosineImpl func(a []float32, b []float32) float32 = CosineImplPure
)

Functions

func CalcFFBatch

func CalcFFBatch(dim int64, left []float32, lIndex int64, right []float32, metric string, result *[]float32)

CalcFFBatch calculate the distance of @left & @right vectors in batch by given @metic, store result in @result

func CalcFloatDistance

func CalcFloatDistance(dim int64, left, right []float32, metric string) ([]float32, error)

CalcFloatDistance calculate float distance by given metric it will checks input, and calculate the distance concurrently

func CosineImplPure

func CosineImplPure(a []float32, b []float32) float32

func IPImplPure

func IPImplPure(a []float32, b []float32) float32

func L2ImplPure

func L2ImplPure(a []float32, b []float32) float32

func ValidateFloatArrayLength

func ValidateFloatArrayLength(dim int64, length int) error

ValidateFloatArrayLength is used validate float vector length

func ValidateMetricType

func ValidateMetricType(metric string) (string, error)

ValidateMetricType returns metric text or error

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