matrix-sized-0.1.1: Haskell matrix library with interface to C++ linear algebra libraries.

Safe HaskellNone
LanguageHaskell2010

Data.Matrix.Static.Sparse

Contents

Synopsis

Sparse matrix

data SparseMatrix :: MatrixKind where Source #

Column-major mutable matrix.

Constructors

SparseMatrix 

Fields

  • :: (SingI r, SingI c)
     
  • => v a

    Values: stores the coefficient values of the non-zeros.

  • -> Vector CInt

    InnerIndices: stores the row (resp. column) indices of the non-zeros.

  • -> Vector CInt

    OuterStarts: stores for each column (resp. row) the index of the first non-zero in the previous two arrays.

  • -> SparseMatrix r c v a
     
Instances
Factorization SparseMatrix Source # 
Instance details

Defined in Data.Matrix.Static.LinearAlgebra

Methods

eigS :: (SingI k, SingI n, k <= (n - 2)) => Sing k -> SparseMatrix n n Vector Double -> (Matrix k 1 (Complex Double), Matrix n k (Complex Double)) Source #

eigSH :: (SingI k, SingI n, k <= (n - 1)) => Sing k -> SparseMatrix n n Vector Double -> (Matrix k 1 Double, Matrix n k Double) Source #

cholesky :: (Numeric a, SingI n) => SparseMatrix n n Vector a -> SparseMatrix n n Vector a Source #

LinearAlgebra SparseMatrix Source # 
Instance details

Defined in Data.Matrix.Static.LinearAlgebra

Methods

ident :: (Numeric a, SingI n) => SparseMatrix n n Vector a Source #

colSum :: (Numeric a, SingI n, Matrix SparseMatrix Vector a) => SparseMatrix m n Vector a -> Matrix 1 n a Source #

rowSum :: (Numeric a, SingI m, Matrix SparseMatrix Vector a) => SparseMatrix m n Vector a -> Matrix m 1 a Source #

Arithmetic Matrix SparseMatrix Source # 
Instance details

Defined in Data.Matrix.Static.LinearAlgebra

Methods

(@@) :: (Numeric a, SingI n, SingI m, If (Matrix == SparseMatrix) Matrix Matrix ~ mat3) => Matrix n p Vector a -> SparseMatrix p m Vector a -> mat3 n m Vector a Source #

(%+%) :: (Numeric a, SingI n, SingI m, If (Matrix == SparseMatrix) Matrix Matrix ~ mat3) => Matrix n m Vector a -> SparseMatrix n m Vector a -> mat3 n m Vector a Source #

(%-%) :: (Numeric a, SingI n, SingI m, If (Matrix == SparseMatrix) Matrix Matrix ~ mat3) => Matrix n m Vector a -> SparseMatrix n m Vector a -> mat3 n m Vector a Source #

(%*%) :: (Numeric a, SingI n, SingI m, If (Matrix == SparseMatrix) Matrix SparseMatrix ~ mat3) => Matrix n m Vector a -> SparseMatrix n m Vector a -> mat3 n m Vector a Source #

Arithmetic SparseMatrix Matrix Source # 
Instance details

Defined in Data.Matrix.Static.LinearAlgebra

Methods

(@@) :: (Numeric a, SingI n, SingI m, If (SparseMatrix == Matrix) SparseMatrix Matrix ~ mat3) => SparseMatrix n p Vector a -> Matrix p m Vector a -> mat3 n m Vector a Source #

(%+%) :: (Numeric a, SingI n, SingI m, If (SparseMatrix == Matrix) SparseMatrix Matrix ~ mat3) => SparseMatrix n m Vector a -> Matrix n m Vector a -> mat3 n m Vector a Source #

(%-%) :: (Numeric a, SingI n, SingI m, If (SparseMatrix == Matrix) SparseMatrix Matrix ~ mat3) => SparseMatrix n m Vector a -> Matrix n m Vector a -> mat3 n m Vector a Source #

(%*%) :: (Numeric a, SingI n, SingI m, If (SparseMatrix == Matrix) SparseMatrix SparseMatrix ~ mat3) => SparseMatrix n m Vector a -> Matrix n m Vector a -> mat3 n m Vector a Source #

Arithmetic SparseMatrix SparseMatrix Source # 
Instance details

Defined in Data.Matrix.Static.LinearAlgebra

Methods

(@@) :: (Numeric a, SingI n, SingI m, If (SparseMatrix == SparseMatrix) SparseMatrix Matrix ~ mat3) => SparseMatrix n p Vector a -> SparseMatrix p m Vector a -> mat3 n m Vector a Source #

(%+%) :: (Numeric a, SingI n, SingI m, If (SparseMatrix == SparseMatrix) SparseMatrix Matrix ~ mat3) => SparseMatrix n m Vector a -> SparseMatrix n m Vector a -> mat3 n m Vector a Source #

(%-%) :: (Numeric a, SingI n, SingI m, If (SparseMatrix == SparseMatrix) SparseMatrix Matrix ~ mat3) => SparseMatrix n m Vector a -> SparseMatrix n m Vector a -> mat3 n m Vector a Source #

(%*%) :: (Numeric a, SingI n, SingI m, If (SparseMatrix == SparseMatrix) SparseMatrix SparseMatrix ~ mat3) => SparseMatrix n m Vector a -> SparseMatrix n m Vector a -> mat3 n m Vector a Source #

(Vector v a, Zero a) => Matrix SparseMatrix v a Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

Methods

dim :: SparseMatrix r c v a -> (Int, Int) Source #

unsafeIndex :: SparseMatrix r c v a -> (Int, Int) -> a Source #

unsafeFromVector :: (SingI r, SingI c) => v a -> SparseMatrix r c v a Source #

flatten :: SparseMatrix r c v a -> v a Source #

unsafeTakeRow :: SparseMatrix r c v a -> Int -> v a Source #

unsafeTakeColumn :: SparseMatrix r c v a -> Int -> v a Source #

takeDiag :: SparseMatrix r c v a -> v a Source #

transpose :: (SingI r, SingI c) => SparseMatrix r c v a -> SparseMatrix c r v a Source #

thaw :: PrimMonad s => SparseMatrix r c v a -> s (Mutable SparseMatrix r c (Mutable v) (PrimState s) a) Source #

unsafeThaw :: PrimMonad s => SparseMatrix r c v a -> s (Mutable SparseMatrix r c (Mutable v) (PrimState s) a) Source #

freeze :: PrimMonad s => Mutable SparseMatrix r c (Mutable v) (PrimState s) a -> s (SparseMatrix r c v a) Source #

unsafeFreeze :: PrimMonad s => Mutable SparseMatrix r c (Mutable v) (PrimState s) a -> s (SparseMatrix r c v a) Source #

map :: Vector v b => (a -> b) -> SparseMatrix r c v a -> SparseMatrix r c v b Source #

imap :: Vector v b => ((Int, Int) -> a -> b) -> SparseMatrix r c v a -> SparseMatrix r c v b Source #

imapM_ :: (Monad monad, Matrix SparseMatrix v a) => ((Int, Int) -> a -> monad b) -> SparseMatrix r c v a -> monad () Source #

sequence :: (Vector v (monad a), Monad monad) => SparseMatrix r c v (monad a) -> monad (SparseMatrix r c v a) Source #

sequence_ :: (Vector v (monad a), Monad monad) => SparseMatrix r c v (monad a) -> monad () Source #

(Vector v a, Eq (v a)) => Eq (SparseMatrix r c v a) Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

Methods

(==) :: SparseMatrix r c v a -> SparseMatrix r c v a -> Bool #

(/=) :: SparseMatrix r c v a -> SparseMatrix r c v a -> Bool #

(Vector v a, Zero a, Show a) => Show (SparseMatrix r c v a) Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

Methods

showsPrec :: Int -> SparseMatrix r c v a -> ShowS #

show :: SparseMatrix r c v a -> String #

showList :: [SparseMatrix r c v a] -> ShowS #

(Vector v a, Zero a, Store (v a), SingI r, SingI c) => Store (SparseMatrix r c v a) Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

Methods

size :: Size (SparseMatrix r c v a)

poke :: SparseMatrix r c v a -> Poke ()

peek :: Peek (SparseMatrix r c v a)

type Mutable SparseMatrix Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

class Eq a => Zero a where Source #

Methods

zero :: a Source #

Instances
Zero Double Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

Methods

zero :: Double Source #

Zero Float Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

Methods

zero :: Float Source #

Zero Int Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

Methods

zero :: Int Source #

Zero CFloat Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

Methods

zero :: CFloat Source #

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

Defined in Data.Matrix.Static.Sparse

Methods

zero :: [a] Source #

Zero (Complex Double) Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

Zero (Complex Float) Source # 
Instance details

Defined in Data.Matrix.Static.Sparse

Accessors

length information

dim :: Matrix mat v a => mat r c v a -> (Int, Int) Source #

rows :: Matrix m v a => m r c v a -> Int Source #

Derived methods

Return the number of rows

cols :: Matrix m v a => m r c v a -> Int Source #

Return the number of columns

Query

(!) :: forall m r c v a i j. (Matrix m v a, i <= r, j <= c) => m r c v a -> (Sing i, Sing j) -> a Source #

Indexing

takeDiag :: Matrix mat v a => mat r c v a -> v a Source #

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

Unsafe Query

unsafeIndex :: Matrix mat v a => mat r c v a -> (Int, Int) -> a Source #

unsafeTakeRow :: Matrix mat v a => mat r c v a -> Int -> v a Source #

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

unsafeTakeColumn :: Matrix mat v a => mat r c v a -> Int -> v a Source #

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

unsafeTakeColumnC :: (Monad m, Vector v a) => SparseMatrix r c v a -> Int -> ConduitT i (Int, Int, a) m () Source #

Stream a column.

Construction

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

fromTriplet :: forall u r c v a. (Vector u (Int, Int, a), Vector v a, SingI r, SingI c) => u (Int, Int, a) -> SparseMatrix r c v a Source #

O(n) Create matrix from triplet. row and column indices *are not* assumed to be ordered duplicate entries are carried over to the CSR represention

fromTripletC :: forall m r c v a. (Monad m, Vector v a, SingI r, SingI c) => ConduitT () (Int, Int, a) m () -> m (SparseMatrix r c v a) Source #

O(n) Create matrix from triplet. Row and column indices *are not* assumed to be ordered. Duplicate entries are carried over to the CSR represention. NOTE: The Conduit will be consumed twice. Use fromTriplet if generating the Conduit is expensive.

toTriplet :: (Monad m, Vector v a, SingI r, SingI c) => SparseMatrix r c v a -> ConduitT i (Int, Int, a) m () Source #

Convert sparse matrix to triplets in column order.

fromVector :: forall m r c v a. (SingI r, SingI c, Matrix m v a) => v a -> m r c v a Source #

Construct matrix from a vector containg columns.

fromList :: (SingI r, SingI c, Matrix m v a) => [a] -> m r c v a Source #

Construct matrix from a list containg columns.

unsafeFromVector :: (Matrix mat v a, SingI r, SingI c) => v a -> mat r c v a Source #

diag Source #

Arguments

:: (Vector v a, Zero a, SingI n) 
=> Matrix n 1 v a

diagonal

-> SparseMatrix n n v a 

O(m*n) Create a rectangular matrix with default values and given diagonal

diagRect Source #

Arguments

:: (Vector v a, Zero a, SingI r, SingI c, n <= r, n <= c) 
=> Matrix n 1 v a

diagonal

-> SparseMatrix r c v a 

O(m*n) Create a rectangular matrix with default values and given diagonal

Conversions

toDense :: (Zero a, Vector v a, SingI r, SingI c) => SparseMatrix r c v a -> Matrix r c v a Source #

flatten :: Matrix mat v a => mat r c v a -> v a Source #

Convert matrix to vector in column order. Default algorithm is O((m*n) * O(unsafeIndex)).

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

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

Different matrix types

convertAny :: (Matrix m1 v1 a, Matrix m2 v2 a, SingI r, SingI c) => m1 r c v1 a -> m2 r c v2 a Source #

O(m*n) Convert to any type of matrix.