Data.Matrix.Dense
 Stability experimental Maintainer Patrick Perry
 Contents Dense matrix type Creating matrices Special matrices Rows and columns Diagonals Augmenting matrices Matrix multiplication Matrix arithmetic Casting matrices Converting between vectors and matrices Unsafe operations
Description
Synopsis
 type Matrix = DMatrix Imm module BLAS.Matrix.Base module BLAS.Matrix.Immutable module BLAS.Tensor.Base module BLAS.Tensor.Dense.Immutable module BLAS.Tensor.Immutable module BLAS.Tensor.Scalable matrix :: BLAS1 e => (Int, Int) -> [((Int, Int), e)] -> Matrix (m, n) e listMatrix :: Elem e => (Int, Int) -> [e] -> Matrix (m, n) e fromCols :: BLAS1 e => (Int, Int) -> [Vector m e] -> Matrix (m, n) e fromRows :: BLAS1 e => (Int, Int) -> [Vector n e] -> Matrix (m, n) e identity :: BLAS1 e => (Int, Int) -> Matrix (m, n) e row :: Elem e => DMatrix t (m, n) e -> Int -> DVector t n e col :: Elem e => DMatrix t (m, n) e -> Int -> DVector t m e rows :: Elem e => DMatrix t (m, n) e -> [DVector t n e] cols :: Elem e => DMatrix t (m, n) e -> [DVector t m e] diag :: Elem e => DMatrix t (m, n) e -> Int -> DVector t k e submatrix :: Elem e => DMatrix t (m, n) e -> (Int, Int) -> (Int, Int) -> DMatrix t (k, l) e apply :: BLAS2 e => Matrix (m, n) e -> Vector n e -> Vector m e applyMat :: BLAS3 e => Matrix (m, k) e -> Matrix (k, n) e -> Matrix (m, n) e sapply :: BLAS2 e => e -> Matrix (m, n) e -> Vector n e -> Vector m e sapplyMat :: BLAS3 e => e -> Matrix (m, k) e -> Matrix (k, n) e -> Matrix (m, n) e shift :: BLAS1 e => e -> Matrix (m, n) e -> Matrix (m, n) e scale :: BLAS1 e => e -> Matrix (m, n) e -> Matrix (m, n) e invScale :: BLAS1 e => e -> Matrix (m, n) e -> Matrix (m, n) e coerceMatrix :: DMatrix t mn e -> DMatrix t kl e fromRow :: BLAS1 e => Vector n e -> Matrix (one, n) e fromCol :: BLAS1 e => Vector m e -> Matrix (m, one) e unsafeMatrix :: BLAS1 e => (Int, Int) -> [((Int, Int), e)] -> Matrix (m, n) e unsafeRow :: Elem e => DMatrix t (m, n) e -> Int -> DVector t n e unsafeCol :: Elem e => DMatrix t (m, n) e -> Int -> DVector t m e unsafeDiag :: Elem e => DMatrix t (m, n) e -> Int -> DVector t k e unsafeSubmatrix :: Elem e => DMatrix t (m, n) e -> (Int, Int) -> (Int, Int) -> DMatrix t (k, l) e
Dense matrix type
 type Matrix = DMatrix Imm Source
module BLAS.Matrix.Base
module BLAS.Matrix.Immutable
module BLAS.Tensor.Base
module BLAS.Tensor.Dense.Immutable
module BLAS.Tensor.Immutable
module BLAS.Tensor.Scalable
Creating matrices
 matrix :: BLAS1 e => (Int, Int) -> [((Int, Int), e)] -> Matrix (m, n) e Source
Create a new matrix of the given size and initialize the given elements to the given values. All other elements get set to zero.
 listMatrix :: Elem e => (Int, Int) -> [e] -> Matrix (m, n) e Source
Create a new matrix with the given elements in row-major order.
 fromCols :: BLAS1 e => (Int, Int) -> [Vector m e] -> Matrix (m, n) e Source
Create a matrix of the given shape from a list of columns
 fromRows :: BLAS1 e => (Int, Int) -> [Vector n e] -> Matrix (m, n) e Source
Create a matrix of the given shape from a list of rows
Special matrices
 identity :: BLAS1 e => (Int, Int) -> Matrix (m, n) e Source
Get a new matrix of the given shape with ones along the diagonal and zeroes everywhere else.
Rows and columns
 row :: Elem e => DMatrix t (m, n) e -> Int -> DVector t n e Source
Get a vector view of the given row in a matrix.
 col :: Elem e => DMatrix t (m, n) e -> Int -> DVector t m e Source
Get a vector view of the given column in a matrix.
 rows :: Elem e => DMatrix t (m, n) e -> [DVector t n e] Source
Get a list of vector views of the rows of the matrix.
 cols :: Elem e => DMatrix t (m, n) e -> [DVector t m e] Source
Get a list of vector views of the columns of the matrix.
Diagonals
 diag :: Elem e => DMatrix t (m, n) e -> Int -> DVector t k e Source
diag a 0 gets a vector view of the main diagonal of a. diag a k for k positive gets a view of the kth superdiagonal. For k negative, it gets a view of the (-k)th subdiagonal.
Augmenting matrices
 submatrix :: Elem e => DMatrix t (m, n) e -> (Int, Int) -> (Int, Int) -> DMatrix t (k, l) e Source
submatrix a ij mn returns a view of the submatrix of a with element (0,0) being element ij in a, and having shape mn.
Matrix multiplication
 apply :: BLAS2 e => Matrix (m, n) e -> Vector n e -> Vector m e Source
Multiply a matrix by a vector.
 applyMat :: BLAS3 e => Matrix (m, k) e -> Matrix (k, n) e -> Matrix (m, n) e Source
Multiply a matrix by a matrix.
 sapply :: BLAS2 e => e -> Matrix (m, n) e -> Vector n e -> Vector m e Source
Multiply a scaled matrix by a vector.
 sapplyMat :: BLAS3 e => e -> Matrix (m, k) e -> Matrix (k, n) e -> Matrix (m, n) e Source
Multiply a scaled matrix by a matrix.
Matrix arithmetic
 shift :: BLAS1 e => e -> Matrix (m, n) e -> Matrix (m, n) e Source
Form a new matrix by adding a value to every element in a matrix.
 scale :: BLAS1 e => e -> Matrix (m, n) e -> Matrix (m, n) e Source
Create a new matrix by scaling another matrix by the given value.
 invScale :: BLAS1 e => e -> Matrix (m, n) e -> Matrix (m, n) e Source
Form a new matrix by dividing every element by a value.
Casting matrices
 coerceMatrix :: DMatrix t mn e -> DMatrix t kl e Source
Coerce the phantom shape type from one type to another.
Converting between vectors and matrices
 fromRow :: BLAS1 e => Vector n e -> Matrix (one, n) e Source
Get a matrix from a row vector.
 fromCol :: BLAS1 e => Vector m e -> Matrix (m, one) e Source
Get a matrix from a column vector.
Unsafe operations
 unsafeMatrix :: BLAS1 e => (Int, Int) -> [((Int, Int), e)] -> Matrix (m, n) e Source
Same as matrix but does not do any bounds checking.
 unsafeRow :: Elem e => DMatrix t (m, n) e -> Int -> DVector t n e Source
Same as row, but does not do any bounds checking.
 unsafeCol :: Elem e => DMatrix t (m, n) e -> Int -> DVector t m e Source
Same as col, but does not do any bounds checking.
 unsafeDiag :: Elem e => DMatrix t (m, n) e -> Int -> DVector t k e Source
Same as diag, but does not do any bounds checking.
 unsafeSubmatrix :: Elem e => DMatrix t (m, n) e -> (Int, Int) -> (Int, Int) -> DMatrix t (k, l) e Source
Same as submatrix but does not do any bounds checking.