Safe Haskell | Safe-Infered |
---|
Naive implementation of simple matrix library.
- data Matrix i b
- matrixInvariant :: (Num i, Ix i) => Matrix i b -> Bool
- data Size i = Size {}
- sizeInvariant :: (Ord i, Num i) => Size i -> Bool
- data MIx i = MIx {}
- mIxInvariant :: (Ord i, Num i) => MIx i -> Bool
- fromLists :: (Num i, Ix i) => Size i -> [[b]] -> Matrix i b
- fromIndexList :: (Num i, Ix i) => Size i -> [(MIx i, b)] -> Matrix i b
- toLists :: (Ix i, Num i, Enum i) => Matrix i b -> [[b]]
- zipWith :: (a -> b -> c) -> Matrix Integer a -> Matrix Integer b -> Matrix Integer c
- matrix :: (Arbitrary i, Integral i, Ix i, Arbitrary b) => Size i -> Gen (Matrix i b)
- matrixUsingRowGen :: (Arbitrary i, Integral i, Ix i, Arbitrary b) => Size i -> (i -> Gen [b]) -> Gen (Matrix i b)
- size :: Ix i => Matrix i b -> Size i
- square :: Ix i => Matrix i b -> Bool
- isEmpty :: (Num i, Ix i) => Matrix i b -> Bool
- add :: (Ix i, Num i) => (a -> b -> c) -> Matrix i a -> Matrix i b -> Matrix i c
- mul :: (Enum i, Num i, Ix i) => Semiring a -> Matrix i a -> Matrix i a -> Matrix i a
- diagonal :: (Enum i, Num i, Ix i) => Matrix i b -> Array i b
- addRow :: (Ix i, Integral i) => b -> Matrix i b -> Matrix i b
- addColumn :: (Ix i, Num i, Enum i) => b -> Matrix i b -> Matrix i b
- tests :: IO Bool
Basic data types
Type of matrices, parameterised on the type of values.
Size of a matrix.
Type of matrix indices (row, column).
Generating and creating matrices
fromIndexList :: (Num i, Ix i) => Size i -> [(MIx i, b)] -> Matrix i bSource
Constructs a matrix from a list of (index, value)-pairs.
toLists :: (Ix i, Num i, Enum i) => Matrix i b -> [[b]]Source
Converts a matrix to a list of row lists.
matrix :: (Arbitrary i, Integral i, Ix i, Arbitrary b) => Size i -> Gen (Matrix i b)Source
Generates a matrix of the given size.
:: (Arbitrary i, Integral i, Ix i, Arbitrary b) | |
=> Size i | |
-> (i -> Gen [b]) | The generator is parameterised on the size of the row. |
-> Gen (Matrix i b) |
Generates a matrix of the given size, using the given generator to generate the rows.
Combining and querying matrices
Modifying matrices
addRow :: (Ix i, Integral i) => b -> Matrix i b -> Matrix i bSource
adds a new row to addRow
x mm
, after the rows already
existing in the matrix. All elements in the new row get set to x
.
addColumn :: (Ix i, Num i, Enum i) => b -> Matrix i b -> Matrix i bSource
adds a new column to addColumn
x mm
, after the columns
already existing in the matrix. All elements in the new column get
set to x
.