-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A native implementation of matrix operations. -- -- Matrix type and basic operations. Just a preliminary version without -- too many features. @package matrix @version 0.1 -- | Matrix datatype an basic operations. module Data.Matrix data Matrix a -- | Display a matrix as a String. prettyMatrix :: Show a => Matrix a -> String -- | Number of rows. nrows :: Matrix a -> Int -- | Number of columns. ncols :: Matrix a -> Int -- | The zero matrix of the given size. zero :: Num a => Int -> Int -> Matrix a -- | Identity matrix of the given order. identity :: Num a => Int -> Matrix a -- | Generate a matrix from a generator function. matrix :: Int -> Int -> ((Int, Int) -> a) -> Matrix a -- | Get an element of a matrix. getElem :: Int -> Int -> Matrix a -> a -- | Nice alias for getElem. (!) :: Matrix a -> (Int, Int) -> a -- | The transpose of a matrix. transpose :: Matrix a -> Matrix a -- | Extend a matrix to a given size adding zeroes. If the matrix already -- has the required size, nothing happens. extendTo :: Num a => Int -> Int -> Matrix a -> Matrix a -- | Extract a submatrix. submatrix :: Int -> Int -> Int -> Int -> Matrix a -> Matrix a -- | Make a block-partition of a matrix using a given element as reference. -- The element will stay in the bottom-right corner of the top-left -- corner matrix. -- --
-- ( ) ( | )
-- ( ) ( ... | ... )
-- ( x ) ( x | )
-- splitBlocks i j ( ) = (-------------) , where x = a_{i,j}
-- ( ) ( | )
-- ( ) ( ... | ... )
-- ( ) ( | )
--
--
-- Note that some blocks can end up empty. We use the following notation
-- for these blocks:
--
-- -- ( TL | TR ) -- (---------) -- ( BL | BR ) ---- -- Where T = Top, B = Bottom, L = Left, R = Right. -- -- Implementation is done via slicing of vectors. splitBlocks :: Int -> Int -> Matrix a -> (Matrix a, Matrix a, Matrix a, Matrix a) -- | Horizontally join two matrices. Visually: -- --
-- ( A ) <|> ( B ) = ( A | B ) ---- -- Where both matrices A and B have the same number of -- rows. (<|>) :: Matrix a -> Matrix a -> Matrix a -- | Vertically join two matrices. Visually: -- --
-- ( A ) -- ( A ) <-> ( B ) = ( - ) -- ( B ) ---- -- Where both matrices A and B have the same number of -- columns. (<->) :: Matrix a -> Matrix a -> Matrix a -- | Join blocks of the form detailed in splitBlocks. joinBlocks :: (Matrix a, Matrix a, Matrix a, Matrix a) -> Matrix a instance Eq a => Eq (Matrix a) instance Num a => Num (Matrix a) instance Functor Matrix instance NFData a => NFData (Matrix a) instance Show a => Show (Matrix a)