matrices-0.4.3: native matrix based on vector

Safe HaskellNone
LanguageHaskell2010

Data.Matrix.Generic

Contents

Synopsis

Documentation

type family Mutable m :: (* -> * -> *) -> * -> * -> * Source

Instances

type Mutable SymMatrix = SymMMatrix Source 
type Mutable CSR = MMatrix Source

mutable sparse matrix not implemented

type Mutable Matrix = MMatrix Source 

class (MMatrix (Mutable m) (Mutable v) a, Vector v a) => Matrix m v a where Source

Methods

dim :: m v a -> (Int, Int) Source

unsafeIndex :: m v a -> (Int, Int) -> a Source

unsafeFromVector :: (Int, Int) -> v a -> m v a Source

flatten :: m v a -> v a Source

Default algorithm is O((m*n) * O(unsafeIndex)).

unsafeTakeRow :: m v a -> Int -> v a Source

Extract a row. Default algorithm is O(n * O(unsafeIndex)).

unsafeTakeColumn :: m v a -> Int -> v a Source

Extract a column. Default algorithm is O(m * O(unsafeIndex)).

takeDiag :: m v a -> v a Source

Extract the diagonal. Default algorithm is O(min(m,n) * O(unsafeIndex)).

thaw :: PrimMonad s => m v a -> s (Mutable m (Mutable v) (PrimState s) a) Source

unsafeThaw :: PrimMonad s => m v a -> s (Mutable m (Mutable v) (PrimState s) a) Source

freeze :: PrimMonad s => Mutable m (Mutable v) (PrimState s) a -> s (m v a) Source

unsafeFreeze :: PrimMonad s => Mutable m (Mutable v) (PrimState s) a -> s (m v a) Source

Instances

Vector v a => Matrix SymMatrix v a Source 
(Zero a, Vector v a) => Matrix CSR v a Source 
Vector v a => Matrix Matrix v a Source 

Derived mothods

rows :: Matrix m v a => m v a -> Int Source

Derived methods

Return the number of rows

cols :: Matrix m v a => m v a -> Int Source

Return the number of columns

(!) :: Matrix m v a => m v a -> (Int, Int) -> a Source

Indexing

fromVector :: Matrix m v a => (Int, Int) -> v a -> m v a Source

fromList :: Matrix m v a => (Int, Int) -> [a] -> m v a Source

empty :: Matrix m v a => m v a Source

toList :: Matrix m v a => m v a -> [a] Source

O(m*n) Create a list by concatenating rows

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

matrix Source

Arguments

:: Matrix m v a 
=> Int

number of columns

-> [a]

row list

-> m v a 

O(m*n) Matrix construction

fromRows :: Matrix m v a => [v a] -> m v a Source

O(m*n) Create matrix from rows

takeRow :: Matrix m v a => m v a -> Int -> v a Source

Extract a row.

toRows :: Matrix m v a => m v a -> [v a] Source

O(m) Return the rows

takeColumn :: Matrix m v a => m v a -> Int -> v a Source

Extract a row.

toColumns :: Matrix m v a => m v a -> [v a] Source

O(m*n) Return the columns

toLists :: Matrix m v a => m v a -> [[a]] Source

O(m*n) List of lists

create :: Matrix m v a => (forall s. ST s (Mutable m (Mutable v) s a)) -> m v a Source