Matrix
Type Classes
Methods
matrixFromList :: Int -> Int -> [a] -> IO (Matrix a)
matrixGet :: (Matrix a) -> Int -> Int -> IO a
matrixZeros :: Int -> Int -> IO (Matrix a)
matrixIdentity :: Int -> IO (Matrix a)
matrixMatmul :: (Matrix a) -> (Matrix a) -> IO (Matrix a)
matrixTranspose :: (Matrix a) -> IO (Matrix a)
matrixAdd :: (Matrix a) -> (Matrix a) -> IO (Matrix a)
matrixScale :: a -> (Matrix a) -> IO (Matrix a)
matrixTrace :: (Matrix a) -> IO a
matrixNorm :: (Matrix a) -> IO a
Functions
O(r*c). Create a matrix of zeros.
O(r*c). Create a matrix of ones.
O(r*c). Create a matrix filled with a constant value.
O(r*c). Create a matrix from nested lists (row-major order).
O(r*c). Create a matrix from a flat list with specified dimensions.
O(r*c). Create a matrix from a list of row vectors.
O(r*c). Create a matrix from a list of column vectors.
O(n²). Create an n×n identity matrix.
O(n²). Create a diagonal matrix from a list of elements.
O(1). The number of rows in a matrix.
O(1). The number of columns in a matrix.
O(1). The total number of elements in a matrix.
O(1). The shape of a matrix as a (rows, cols) tuple.
O(1). Safe indexing into a matrix.
O(min(r,c)). Get the main diagonal as a vector.
Drop first n rows.
Take first n columns.
Drop first n columns.
Horizontal concatenation.
zipWith :: (MatrixElem a, MatrixElem b, MatrixElem c) => (a -> b -> c) -> (Matrix a) -> (Matrix b) -> Matrix c zipWith f ma mb
#
izipWith :: (MatrixElem a, MatrixElem b, MatrixElem c) => (Int -> Int -> a -> b -> c) -> (Matrix a) -> (Matrix b) -> Matrix c izipWith f ma mb
#
Scale matrix by scalar.
O(n·m). Matrix-vector multiplication.
O(1). The number of columns in a matrix.
O(n³). Matrix rank via SVD.
O(n³). Matrix inverse using Gauss-Jordan elimination.
O(1). The number of columns in a matrix.
gaussJordanInverse :: (Fractional a, Ord a, MatrixElem a) => (Matrix a) -> Matrix a gaussJordanInverse m
#
Gauss-Jordan elimination for matrix inverse.
gaussElim :: (Fractional a, Ord a, MatrixElem a) => Int -> Int -> (Matrix a) -> Matrix a gaussElim nRows nCols m
#
Solve linear system Ax = b.
Back substitution for Ux = b (U is upper triangular).
LU decomposition.
luWithPivot :: (Fractional a, Ord a, MatrixElem a) => (Matrix a) -> (Matrix a, Matrix a, Matrix a, Int) luWithPivot m
#
O(1). The number of columns in a matrix.
Singular value decomposition.
Power iteration for multiple eigenvectors.
Cholesky decomposition.
O(1). The number of columns in a matrix.
Eigenvalues only.
Back substitution for rectangular upper triangular system.
2-norm (spectral norm, largest singular value).
Frobenius norm (sqrt of sum of squares).
Sum each column.
Mean of each row.
Mean of each column.
Convert to nested lists.
View vector as 1-column matrix.
View vector as 1-row matrix.