Module

# LinearAlgebra.Matrix

Package
purescript-linalg
Repository
gbagan/purescript-linalg

### #MatrixSource

``newtype Matrix a``

#### Instances

• `(Eq a) => Eq (Matrix a)`
• `Functor Matrix`
• `(Show a) => Show (Matrix a)`

### #SolutionsSource

``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 }

### #fromArraySource

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

### #fromFunctionSource

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

### #fromColumnsSource

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

### #eyeSource

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

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

### #diagSource

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

### #mapWithIndexSource

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

### #toArraySource

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

### #ncolsSource

``ncols :: forall a. Matrix a -> Int``

### #nrowsSource

``nrows :: forall a. Matrix a -> Int``

### #columnSource

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

### #rowSource

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

### #columnsSource

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

### #rowsSource

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

### #indexSource

``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 :: forall a. Semiring a => Matrix a -> Matrix a -> Matrix a``

### #diffSource

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

### #scaleSource

``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

### #multSource

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

### #mult'Source

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

### #kroneckerSource

``kronecker :: forall a. Semiring a => Matrix a -> Matrix a -> Matrix a``

Kronecker product https://en.wikipedia.org/wiki/Kronecker_product

### #transposeSource

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

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

### #inverseSource

``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

### #kernelSource

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

### #imageSource

``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

### #determinantSource

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

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

### #rankSource

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

computes the rank of the matrix

### #traceSource

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

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

### #gaussJordanSource

``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

### #solveLinearSystemSource

``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