Module

LinearAlgebra.Matrix

Package
purescript-linalg
Repository
gbagan/purescript-linalg

#Matrix Source

data 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. Array (Array a) -> Matrix a

#fromFunction Source

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

#invalid Source

invalid :: forall a. Matrix a

#isValid Source

isValid :: forall a. Matrix a -> Boolean

#identity Source

identity :: forall a. Field a => Int -> Matrix a

computes the identity matrix of size n https://en.wikipedia.org/wiki/Identity_matrix

#ncols Source

ncols :: forall a. Matrix a -> Int

#nrows Source

nrows :: forall a. Matrix a -> Int

#elem Source

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

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

#elem' Source

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

#mapWithIndex Source

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

#row Source

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

#column Source

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

#rows Source

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

#columns Source

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

#transpose Source

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

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

#add Source

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

computes the addition of two matrices https://en.wikipedia.org/wiki/Matrix_addition

#diff Source

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

#smult Source

smult :: 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

#inverse Source

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

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

#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

#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)

#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

#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

#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)

#rank Source

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

computes the rank of the matrix

#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