matrix

package
v0.0.0-...-889d575 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDivByZero = errors.New("divide by zero")
View Source
var ErrMatNotCompatible = errors.New("matrices are not compatible")
View Source
var ErrMatNotSquare = errors.New("vector size missmatch")
View Source
var ErrMatSingular = errors.New("singular matrix")
View Source
var ErrMatSizeMissmatch = errors.New("matrix size missmatch")
View Source
var ErrVecSizeMissmatch = errors.New("vector size missmatch")

Functions

func GetCol

func GetCol[Num Number](input [][]Num, col int) (resVal []Num)

GetCol extracts a given column out from a 2D slice (matrix)

func GetRow

func GetRow[Num Number](input [][]Num, row int) (output []Num)

GetRow extracts a given row out from a 2D slice (matrix)

func IsSquare

func IsSquare[Num Number](input [][]Num) (is bool, matSize [2]int)

IsSquare checks if a matrix is squared (i.e. rows == columns)

func MatrixAdd

func MatrixAdd[Num Number](a, b [][]Num) (resVal [][]Num, err error)

MatrixAdd adds two 2D matrices of the same size Input: a, b are two matrices of the form [rows][column]Matrix Output: resVal is the sum matrix

func MatrixDetComp

func MatrixDetComp[Num constraints.Complex](matrix [][]Num) (det Num, err error)

MatrixDet returns the Determinant of a square matrix using LU factorization Input: matrix is a matrix of the form [rows][column]Matrix Output: det is the determinant of the matrix

func MatrixDetReal

func MatrixDetReal[Num Real](matrix [][]Num) (det Num, err error)

MatrixDet returns the Determinant of a square matrix using LU factorization Input: matrix is a matrix of the form [rows][column]Matrix Output: det is the determinant of the matrix

func MatrixMult

func MatrixMult[Num Number](a, b [][]Num) (resVal [][]Num, err error)

MatrixMult implements the multiplication of two matrix using the naive approach Input: a, and b are two compatible matrices of the form [rows][column]Matrix Output: resVal is the scalar multiblication scal * [][]matr

func MatrixScalMult

func MatrixScalMult[Num Number](matr [][]Num, scal Num) (resVal [][]Num)

MatrixScalMult implements the scalar multiplication of a matrix Input: matr is a matrix of the form [rows][column]Matrix scal is a scalar value Output: resVal is the scalar multiblication scal * [][]matr

func MatrixSize

func MatrixSize[Num Number](input [][]Num) (matrixSize [2]int)

MatrixSize estimates the size of a 2D matrix Input: input is the numerical input matrix of the form [rows][column]Matrix Output: matrixSize is a vector with the size of the matrix [rows, columns]

func MatrixSub

func MatrixSub[Num Number](a, b [][]Num) (resVal [][]Num, err error)

MatrixSub adds two 2D matrices of the same size Input: a, b are two matrices of the form [rows][column]Matrix Output: resVal is the substraction matrix

func VectScalMult

func VectScalMult[Num Number](a, b []Num) (resVal Num, err error)

VectScalMult implements the scalar multiplication of vectors Input: a, and b are two equaly sized (equal number of components) vectors of the form []Vector Output: resVal is the scalar multiblication []a * b[]

Types

type Number

type Number interface {
	constraints.Float | constraints.Integer | constraints.Complex
}

Set of all numbers R(real) U C(complex) U i(imaginary)

type Real

type Real interface {
	constraints.Float | constraints.Integer
}

Set of Real Numbers

Jump to

Keyboard shortcuts

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