algorithms

package
v0.0.0-...-402592c Latest Latest
Warning

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

Go to latest
Published: May 24, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EuclideanNormSquared

func EuclideanNormSquared(vector mat.Vector) float64

EuclideanNormSquared returns the squared euclidean norm of a mat.Vector.

@param vector : mat.Vector -- The vector for which you need the squared euclidean norm Returns a float64 value

func FrobeniusSquared

func FrobeniusSquared(matrix *mat.Dense) float64

FrobeniusSquared returns the squared frobenius norm of a mat.Dense matrix

func GetRandomRow

func GetRandomRow(rowsProb []float64) int

GetRandomRow performs weighted sampling with the weights you provide in the rowsProb array

The scope of this function is to return a random row index for the RkRk and RkRek algorithms. Each row probability is computed by GetRowsProbability method

func GetRowsProbability

func GetRowsProbability(probVector []float64, frobenius float64, matrix *mat.Dense, rownum int, group *sync.WaitGroup)

GetRowsProbability computes the probabilities of choosing a random row from a matrix

The probability is computed as the squared euclidean norm of the row divided by the squared frobenius norm of the matrix

Since this method is intended to be used with the RkRk and RkRek algorithms which require computing the probabilities of many rows, this method requires a WaitGroup and has multithreaded behaviour.

func RkRek

func RkRek(U, V *mat.Dense, y *mat.VecDense, iterations int, tolerance float64, keepErrors ...bool) (mat.VecDense, []float64)

RkRek returns the min-norm least-squares solution of a system A*b=y

Parameters: U and V are two matrices such that U*V=A. y is a vector such that A*b=y. iterations is the maximum number of iterations the algorithm is allowed to perform. tolerance is the desired error. keepErrors is an optional boolean specifying whether to keep the errors calculated at each step.

Returns the b vector which is the solution to A*b=y and an array of errors.

Notes: Pass a negative number as the iterations number to default to 100_000. Only the first value in keepErrors is evaluated. If keepErrors[0] is false then the returned errors array will be empty.

func RkRk

func RkRk(U, V *mat.Dense, y *mat.VecDense, iterations int, tolerance float64, keepErrors ...bool) (mat.VecDense, []float64)

RkRk returns the minimum norm solution to the system A*b=y, where A=U*V Knowing the whole matrix A is unnecessary and so it is never computed by the algorithm.

Parameters: U, V are mat.Dense matrices that are a defactorization of A. y is mat.VecDense vector that represents the expected output for the system. iterations is an int representing how many times MAX is the algorithm allowed to run. tolerance is a float64 that represents the maximal error allowed. keepErrors is an optional boolean that specifies whether you want the function to retain the error at each iteration.

Returns the vector b that solves A*b=y and a []float64 array containing the errors at each iteration.

Notes: Pass a negative number as the iteration to use the default value of 100_000 Even though you can pass as many boolean values for keepErrors only the first will be taken into account

Types

This section is empty.

Jump to

Keyboard shortcuts

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