matrices-0.4.5: native matrix based on vector

Safe Haskell None Haskell2010

Data.Matrix.Sparse.Generic

Synopsis

# Documentation

class Eq a => Zero a where Source #

Minimal complete definition

zero

Methods

zero :: a Source #

Instances

 Source # Methods Source # Methods Eq a => Zero [a] Source # Methodszero :: [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 # Methodsdim :: 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 # Methods(==) :: CSR v a -> CSR v a -> Bool #(/=) :: CSR v a -> CSR v a -> Bool # Read (v a) => Read (CSR v a) Source # MethodsreadsPrec :: 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 # MethodsshowsPrec :: Int -> CSR v a -> ShowS #show :: CSR v a -> String #showList :: [CSR v a] -> ShowS # Generic (CSR v a) Source # Associated Typestype Rep (CSR v a) :: * -> * # Methodsfrom :: CSR v a -> Rep (CSR v a) x #to :: Rep (CSR v a) x -> CSR v a # type Mutable CSR Source # type Mutable CSR = MMatrix type Rep (CSR v a) Source # type Rep (CSR v a) = D1 (MetaData "CSR" "Data.Matrix.Sparse.Generic" "matrices-0.4.5-FxXj00niP442mTwOHbDHPt" False) (C1 (MetaCons "CSR" PrefixI False) ((:*:) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int))) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (v a))) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Vector Int))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Vector Int)))))))

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 #

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