Module

Data.LinearAlgebra.Matrix

Package
purescript-linalg
Repository
gbagan/purescript-linalg

#Matrix Source

newtype Matrix a

Instances

#Solutions Source

type Solutions a = { basis :: Array (Vector a), sol :: Vector a }

Represents the set of solutions for the function solveLinearSystem. The set of solutions is { sol + v | v is a linear combination of vectors in basis }

#fromArray Source

fromArray :: forall a. Semiring a => Int -> Int -> Array (Array a) -> Matrix a

#fromFunction Source

fromFunction :: forall a. Int -> Int -> (Int -> Int -> a) -> Matrix a

#fromColumns Source

fromColumns :: forall a. Semiring a => Int -> Int -> Array (Vector a) -> Matrix a

#eye Source

eye :: forall a. Semiring a => Int -> Matrix a

computes the identity matrix of dimension nxn https://en.wikipedia.org/wiki/Identity_matrix

#diag Source

diag :: forall a. Semiring a => Array a -> Matrix a

#mapWithIndex Source

mapWithIndex :: forall a b. (Int -> Int -> a -> b) -> Matrix a -> Matrix b

#toArray Source

toArray :: forall a. Matrix a -> Array (Array a)

#ncols Source

ncols :: forall a. Matrix a -> Int

#nrows Source

nrows :: forall a. Matrix a -> Int

#column Source

column :: forall a. Matrix a -> Int -> Vector a

#columns Source

columns :: forall a. Matrix a -> Array (Vector a)

#index Source

index :: forall a. Semiring a => Matrix a -> Int -> Int -> a

returns the element at indices (i, j) returns zero if the indices are not valid

#index' Source

index' :: forall a. Matrix a -> Int -> Int -> Maybe a

#add Source

add :: forall a. Semiring a => Matrix a -> Matrix a -> Matrix a

#diff Source

diff :: forall a. Ring a => Matrix a -> Matrix a -> Matrix a

#scale Source

scale :: forall a. Semiring a => a -> Matrix a -> Matrix a

computes the (left) scalar multiplication of a matrice https://en.wikipedia.org/wiki/Scalar_multiplication

#mult Source

mult :: forall a. Semiring a => Matrix a -> Matrix a -> Matrix a

#mult' Source

mult' :: forall a. Semiring a => Matrix a -> Vector a -> Vector a

#kronecker Source

#transpose Source

transpose :: forall a. Matrix a -> Matrix a

computes the transpose of the matrix https://en.wikipedia.org/wiki/Transpose

#inverse Source

inverse :: forall a. Eq a => Field a => Matrix a -> Maybe (Matrix a)

computes the inverse of the matrix using Gauss-Jordan Elimination and augmented matrix https://en.wikipedia.org/wiki/Invertible_matrix#Gaussian_elimination

#kernel Source

kernel :: forall a. Eq a => Field a => Matrix a -> Array (Vector a)

computes a basis for the kernel (or null space) of the matrix https://en.wikipedia.org/wiki/Kernel_(linear_algebra)

#image Source

image :: forall a. Eq a => Field a => Matrix a -> Array (Vector a)

computes a basis the image (or column space) of the matrix https://en.wikipedia.org/wiki/Row_and_column_spaces

#determinant Source

determinant :: forall a. Eq a => Field a => Matrix a -> a

computes the determinant of a square matrix https://en.wikipedia.org/wiki/Determinant

#rank Source

rank :: forall a. Eq a => Field a => Matrix a -> Int

computes the rank of the matrix

#trace Source

trace :: forall a. Eq a => Semiring a => Matrix a -> a

computes the trace of the matrix https://en.wikipedia.org/wiki/Trace_(linear_algebra)

#gaussJordan Source

gaussJordan :: forall a. Eq a => Field a => Matrix a -> { det :: a, mat :: Matrix a }

computes the reduced row echelon form of the matrix and compute its determinant if the matrix is square see https://en.wikipedia.org/wiki/Row_echelon_form

#solveLinearSystem Source

solveLinearSystem :: forall a. Eq a => Field a => Matrix a -> Vector a -> Maybe (Solutions a)

solve the equation M x = b for a given matrix M and vector b

#solveLinearSystem' Source

solveLinearSystem' :: forall a. Eq a => Field a => Matrix a -> Vector a -> Maybe (Vector a)

same as solveLinearSystem but without basis