matrices-0.4.1: 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 
Zero Int 
Eq a => Zero [a] 

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 
Show (v a) => Show (CSR v a) 
type Mutable CSR = MMatrix

mutable sparse matrix not implemented

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