matrices-0.5.0: native matrix based on vector

Safe HaskellNone
LanguageHaskell2010

Data.Matrix.Sparse.Generic

Contents

Synopsis

Documentation

class Eq a => Zero a where Source #

Methods

zero :: a Source #

Instances
Zero Double Source # 
Instance details

Defined in Data.Matrix.Sparse.Generic

Methods

zero :: Double Source #

Zero Int Source # 
Instance details

Defined in Data.Matrix.Sparse.Generic

Methods

zero :: Int Source #

Eq a => Zero [a] Source # 
Instance details

Defined in Data.Matrix.Sparse.Generic

Methods

zero :: [a] Source #

data CSR v a Source #

Compressed Sparse Row (CSR) matrix

Constructors

CSR !Int !Int !(v a) !(Vector Int) !(Vector Int) 
Instances
(Zero a, Vector v a) => Matrix CSR v a Source # 
Instance details

Defined in Data.Matrix.Sparse.Generic

Methods

dim :: CSR v a -> (Int, Int) Source #

unsafeIndex :: CSR v a -> (Int, Int) -> a Source #

unsafeFromVector :: (Int, Int) -> v a -> CSR v a Source #

flatten :: CSR v a -> v a Source #

unsafeTakeRow :: CSR v a -> Int -> v a Source #

unsafeTakeColumn :: CSR v a -> Int -> v a Source #

takeDiag :: CSR v a -> v a Source #

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

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

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

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

Eq (v a) => Eq (CSR v a) Source # 
Instance details

Defined in Data.Matrix.Sparse.Generic

Methods

(==) :: CSR v a -> CSR v a -> Bool #

(/=) :: CSR v a -> CSR v a -> Bool #

Read (v a) => Read (CSR v a) Source # 
Instance details

Defined in Data.Matrix.Sparse.Generic

Methods

readsPrec :: Int -> ReadS (CSR v a) #

readList :: ReadS [CSR v a] #

readPrec :: ReadPrec (CSR v a) #

readListPrec :: ReadPrec [CSR v a] #

Show (v a) => Show (CSR v a) Source # 
Instance details

Defined in Data.Matrix.Sparse.Generic

Methods

showsPrec :: Int -> CSR v a -> ShowS #

show :: CSR v a -> String #

showList :: [CSR v a] -> ShowS #

Generic (CSR v a) Source # 
Instance details

Defined in Data.Matrix.Sparse.Generic

Associated Types

type Rep (CSR v a) :: Type -> Type #

Methods

from :: CSR v a -> Rep (CSR v a) x #

to :: Rep (CSR v a) x -> CSR v a #

type Mutable CSR Source #

mutable sparse matrix not implemented

Instance details

Defined in Data.Matrix.Sparse.Generic

type Rep (CSR v a) Source # 
Instance details

Defined in Data.Matrix.Sparse.Generic

type AssocList a = [((Int, Int), a)] Source #

Accessors

length information

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

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

Indexing

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

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

Indexing

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

Extract a row.

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

fromAscAL :: Vector v a => (Int, Int) -> Int -> AssocList a -> CSR v a Source #

Construct CSR from ascending association list. Items must be sorted first by row index, and then by column index.

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

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

matrix Source #

Arguments

:: Matrix m v a 
=> Int

number of columns

-> [a]

row list

-> m v a 

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

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

O(m*n) Create matrix from rows

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

Conversions

flatten :: Matrix m v a => m v a -> v a Source #

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

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

O(m) Return the rows

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

O(m*n) Return the columns

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

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

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

O(m*n) List of lists