Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Matrix v a = Matrix !Int !Int !Int !Int !(v a)
- dim :: Matrix m v a => m v a -> (Int, Int)
- rows :: Matrix m v a => m v a -> Int
- cols :: Matrix m v a => m v a -> Int
- unsafeIndex :: Matrix m v a => m v a -> (Int, Int) -> a
- (!) :: Matrix m v a => m v a -> (Int, Int) -> a
- takeRow :: Matrix m v a => m v a -> Int -> v a
- takeColumn :: Matrix m v a => m v a -> Int -> v a
- takeDiag :: Matrix m v a => m v a -> v a
- unsafeFromVector :: Matrix m v a => (Int, Int) -> v a -> m v a
- fromVector :: Matrix m v a => (Int, Int) -> v a -> m v a
- matrix :: Matrix m v a => Int -> [a] -> m v a
- fromList :: Matrix m v a => (Int, Int) -> [a] -> m v a
- fromLists :: Matrix m v a => [[a]] -> m v a
- fromRows :: Matrix m v a => [v a] -> m v a
- fromColumns :: Vector v a => [v a] -> Matrix v a
- empty :: Matrix m v a => m v a
- flatten :: Matrix m v a => m v a -> v a
- toRows :: Matrix m v a => m v a -> [v a]
- toColumns :: Matrix m v a => m v a -> [v a]
- toList :: Matrix m v a => m v a -> [a]
- toLists :: Matrix m v a => m v a -> [[a]]
- convert :: (Vector v a, Vector w a) => Matrix v a -> Matrix w a
- tr :: Vector v a => Matrix v a -> Matrix v a
- subMatrix :: Vector v a => (Int, Int) -> (Int, Int) -> Matrix v a -> Matrix v a
- ident :: (Num a, Vector v a) => Int -> Matrix v a
- diag :: (Num a, Vector v a, Foldable t) => t a -> Matrix v a
- diagRect :: (Vector v a, Foldable t) => a -> (Int, Int) -> t a -> Matrix v a
- fromBlocks :: Vector v a => a -> [[Matrix v a]] -> Matrix v a
- isSymmetric :: (Eq a, Vector v a) => Matrix v a -> Bool
- force :: Vector v a => Matrix v a -> Matrix v a
- foldl :: Vector v b => (a -> b -> a) -> a -> Matrix v b -> a
- map :: (Vector v a, Vector v b) => (a -> b) -> Matrix v a -> Matrix v b
- imap :: (Vector v a, Vector v b) => ((Int, Int) -> a -> b) -> Matrix v a -> Matrix v b
- mapM :: (Vector v a, Vector v b, Monad m) => (a -> m b) -> Matrix v a -> m (Matrix v b)
- imapM :: (Vector v a, Vector v b, Monad m) => ((Int, Int) -> a -> m b) -> Matrix v a -> m (Matrix v b)
- mapM_ :: (Vector v a, Monad m) => (a -> m b) -> Matrix v a -> m ()
- imapM_ :: (Vector v a, Monad m) => ((Int, Int) -> a -> m b) -> Matrix v a -> m ()
- forM :: (Vector v a, Vector v b, Monad m) => Matrix v a -> (a -> m b) -> m (Matrix v b)
- forM_ :: (Vector v a, Monad m) => Matrix v a -> (a -> m b) -> m ()
- zipWith :: (Vector v a, Vector v b, Vector v c) => (a -> b -> c) -> Matrix v a -> Matrix v b -> Matrix v c
- zipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => (a -> b -> c -> d) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d
- zipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => (a -> b -> c -> d -> e) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e
- zipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => (a -> b -> c -> d -> e -> f) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v f
- zipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => (a -> b -> c -> d -> e -> f -> g) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v f -> Matrix v g
- izipWith :: (Vector v a, Vector v b, Vector v c) => ((Int, Int) -> a -> b -> c) -> Matrix v a -> Matrix v b -> Matrix v c
- izipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => ((Int, Int) -> a -> b -> c -> d) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d
- izipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => ((Int, Int) -> a -> b -> c -> d -> e) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e
- izipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => ((Int, Int) -> a -> b -> c -> d -> e -> f) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v f
- izipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => ((Int, Int) -> a -> b -> c -> d -> e -> f -> g) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v f -> Matrix v g
- zip :: (Vector v a, Vector v b, Vector v (a, b)) => Matrix v a -> Matrix v b -> Matrix v (a, b)
- zip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => Matrix v a -> Matrix v b -> Matrix v c -> Matrix v (a, b, c)
- zip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v (a, b, c, d)
- zip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v (a, b, c, d, e)
- zip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v f -> Matrix v (a, b, c, d, e, f)
- zipWithM :: (Monad m, Vector v a, Vector v b, Vector v c) => (a -> b -> m c) -> Matrix v a -> Matrix v b -> m (Matrix v c)
- zipWithM_ :: (Monad m, Vector v a, Vector v b) => (a -> b -> m c) -> Matrix v a -> Matrix v b -> m ()
- unzip :: (Vector v a, Vector v b, Vector v (a, b)) => Matrix v (a, b) -> (Matrix v a, Matrix v b)
- unzip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => Matrix v (a, b, c) -> (Matrix v a, Matrix v b, Matrix v c)
- unzip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => Matrix v (a, b, c, d) -> (Matrix v a, Matrix v b, Matrix v c, Matrix v d)
- unzip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => Matrix v (a, b, c, d, e) -> (Matrix v a, Matrix v b, Matrix v c, Matrix v d, Matrix v e)
- unzip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => Matrix v (a, b, c, d, e, f) -> (Matrix v a, Matrix v b, Matrix v c, Matrix v d, Matrix v e, Matrix v f)
- sequence :: (Vector v a, Vector v (m a), Monad m) => Matrix v (m a) -> m (Matrix v a)
- sequence_ :: (Vector v (m a), Monad m) => Matrix v (m a) -> m ()
- generate :: Vector v a => (Int, Int) -> ((Int, Int) -> a) -> Matrix v a
- thaw :: (Matrix m v a, PrimMonad s) => m v a -> s (Mutable m (Mutable v) (PrimState s) a)
- unsafeThaw :: (Matrix m v a, PrimMonad s) => m v a -> s (Mutable m (Mutable v) (PrimState s) a)
- freeze :: (Matrix m v a, PrimMonad s) => Mutable m (Mutable v) (PrimState s) a -> s (m v a)
- unsafeFreeze :: (Matrix m v a, PrimMonad s) => Mutable m (Mutable v) (PrimState s) a -> s (m v a)
- create :: Matrix m v a => (forall s. ST s (Mutable m (Mutable v) s a)) -> m v a
Immutable Matrix
Row-major matrix supporting efficient slice.
Instances
Accessors
length information
Indexing
takeColumn :: Matrix m v a => m v a -> Int -> v a Source #
Extract a row.
takeDiag :: Matrix m v a => m v a -> v a Source #
Extract the diagonal. Default algorithm is O(min(m,n) * O(unsafeIndex)).
Construction
O(m*n) Matrix construction
fromLists :: Matrix m v a => [[a]] -> m v a Source #
O(m*n) Create matrix from list of lists, it doesn't check if the list of list is a valid matrix
fromColumns :: Vector v a => [v a] -> Matrix v a Source #
O(m*n) Create matrix from columns
Conversions
Different matrix types
convert :: (Vector v a, Vector w a) => Matrix v a -> Matrix w a Source #
O(m*n) Convert different matrix type
:: Vector v a | |
=> (Int, Int) | upper left corner of the submatrix |
-> (Int, Int) | bottom right corner of the submatrix |
-> Matrix v a | |
-> Matrix v a |
O(1) Extract sub matrix
O(m*n) Create a square matrix with given diagonal, other entries default to 0
O(m*n) Create a rectangular matrix with default values and given diagonal
Mapping
Monadic mapping
imapM :: (Vector v a, Vector v b, Monad m) => ((Int, Int) -> a -> m b) -> Matrix v a -> m (Matrix v b) Source #
O(m*n) Apply the monadic action to every element and its index, yielding a matrix of results.
imapM_ :: (Vector v a, Monad m) => ((Int, Int) -> a -> m b) -> Matrix v a -> m () Source #
O(m*n) Apply the monadic action to every element and its index, ignoring the results.
Zipping
zipWith :: (Vector v a, Vector v b, Vector v c) => (a -> b -> c) -> Matrix v a -> Matrix v b -> Matrix v c Source #
zipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => (a -> b -> c -> d) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d Source #
zipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => (a -> b -> c -> d -> e) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e Source #
zipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => (a -> b -> c -> d -> e -> f) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v f Source #
zipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => (a -> b -> c -> d -> e -> f -> g) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v f -> Matrix v g Source #
izipWith :: (Vector v a, Vector v b, Vector v c) => ((Int, Int) -> a -> b -> c) -> Matrix v a -> Matrix v b -> Matrix v c Source #
izipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => ((Int, Int) -> a -> b -> c -> d) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d Source #
izipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => ((Int, Int) -> a -> b -> c -> d -> e) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e Source #
izipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => ((Int, Int) -> a -> b -> c -> d -> e -> f) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v f Source #
izipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => ((Int, Int) -> a -> b -> c -> d -> e -> f -> g) -> Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v f -> Matrix v g Source #
zip :: (Vector v a, Vector v b, Vector v (a, b)) => Matrix v a -> Matrix v b -> Matrix v (a, b) Source #
zip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => Matrix v a -> Matrix v b -> Matrix v c -> Matrix v (a, b, c) Source #
zip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v (a, b, c, d) Source #
zip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v (a, b, c, d, e) Source #
zip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => Matrix v a -> Matrix v b -> Matrix v c -> Matrix v d -> Matrix v e -> Matrix v f -> Matrix v (a, b, c, d, e, f) Source #
Monadic Zipping
zipWithM :: (Monad m, Vector v a, Vector v b, Vector v c) => (a -> b -> m c) -> Matrix v a -> Matrix v b -> m (Matrix v c) Source #
zipWithM_ :: (Monad m, Vector v a, Vector v b) => (a -> b -> m c) -> Matrix v a -> Matrix v b -> m () Source #
Unzipping
unzip :: (Vector v a, Vector v b, Vector v (a, b)) => Matrix v (a, b) -> (Matrix v a, Matrix v b) Source #
unzip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => Matrix v (a, b, c) -> (Matrix v a, Matrix v b, Matrix v c) Source #
unzip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => Matrix v (a, b, c, d) -> (Matrix v a, Matrix v b, Matrix v c, Matrix v d) Source #
unzip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => Matrix v (a, b, c, d, e) -> (Matrix v a, Matrix v b, Matrix v c, Matrix v d, Matrix v e) Source #
unzip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => Matrix v (a, b, c, d, e, f) -> (Matrix v a, Matrix v b, Matrix v c, Matrix v d, Matrix v e, Matrix v f) Source #
Monadic sequencing
Mutable matrix
unsafeThaw :: (Matrix m v a, PrimMonad s) => m v a -> s (Mutable m (Mutable v) (PrimState s) a) Source #
freeze :: (Matrix m v a, PrimMonad s) => Mutable m (Mutable v) (PrimState s) a -> s (m v a) Source #