distance

package
v0.0.0-...-1593278 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 3 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"
	// HAMMING represents the hamming distance
	HAMMING = "HAMMING"
	// TANIMOTO represents the tanimoto distance
	TANIMOTO = "TANIMOTO"
	// JACCARD in string
	JACCARD = "JACCARD"
	// SUPERSTRUCTURE in string
	SUPERSTRUCTURE = "SUPERSTRUCTURE"
	// SUBSTRUCTURE in string
	SUBSTRUCTURE = "SUBSTRUCTURE"
)

Variables

This section is empty.

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 CalcHamming

func CalcHamming(dim int64, left []byte, lIndex int64, right []byte, rIndex int64) int32

CalcHamming calculate HAMMING distance

func CalcHammingBatch

func CalcHammingBatch(dim int64, left []byte, lIndex int64, right []byte, result *[]int32)

CalcHammingBatch calculate HAMMING distance in batch, results are in @result

func CalcHammingDistance

func CalcHammingDistance(dim int64, left, right []byte) ([]int32, error)

func CalcIP

func CalcIP(dim int64, left []float32, lIndex int64, right []float32, rIndex int64) float32

CalcIP returns the inner product distance of input vectors

func CalcL2

func CalcL2(dim int64, left []float32, lIndex int64, right []float32, rIndex int64) float32

CalcL2 returns the Euclidean distance of input vectors

func CalcTanimotoCoefficient

func CalcTanimotoCoefficient(dim int64, hamming []int32) ([]float32, error)

func CountOne

func CountOne(n uint8) int32

CountOne count 1 of uint8 For 00000010, return 1 Fro 11111111, return 8

func PositivelyRelated

func PositivelyRelated(metricType string) bool

PositivelyRelated return if metricType are "ip" or "IP"

func SingleBitLen

func SingleBitLen(dim int64) int64

SingleBitLen returns the bit length of @dim

func ValidateBinaryArrayLength

func ValidateBinaryArrayLength(dim int64, length int) error

ValidateBinaryArrayLength validates a binary array of @dim & @length

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

func VectorCount

func VectorCount(dim int64, length int) int64

VectorCount counts bits by @dim & @length

Types

This section is empty.

Jump to

Keyboard shortcuts

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