vectors

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package vectors is deprecated.

Package vectors provides basic vector operations.

Deprecated: generic numerical operations are available in package gnum.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a []float64, b ...[]float64) []float64

Add adds b to a and returns a. b is unchanged. If a is nil, creates a new vector.

func Copy

func Copy(a []float64) []float64

Copy returns a copy of the given vector.

func Dot

func Dot(a, b []float64) float64

Dot returns the dot product of the input vectors.

func L1

func L1(a, b []float64) float64

L1 (Manhattan) distance. Equivalent to Lp(1).

func L2

func L2(a, b []float64) float64

L2 (Euclidean) distance. Equivalent to Lp(2).

func Lp

func Lp(p int) func([]float64, []float64) float64

Lp returns an Lp distance function. Lp is calculated as follows:

Lp(v) = the p'th root of sum_i(v[i]^p)

For convenience, L1 (Manhattan)and L2 (Euclidean) are prepared package variables.

func Mul

func Mul(a []float64, m float64) []float64

Mul multiplies the values of a by m and returns a.

func Norm

func Norm(a []float64) float64

Norm returns the norm of the vector, in L2.

func Ones

func Ones(n int) []float64

Ones returns a slice of ones of length n. Panics if n is negative.

func Sub

func Sub(a []float64, b ...[]float64) []float64

Sub subtracts b from a and returns a. b is unchanged. If a is nil, creates a new vector.

Types

This section is empty.

Jump to

Keyboard shortcuts

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