sparse-linear-algebra-0.3.1: Numerical computing in native Haskell

Copyright(C) 2016 Marco Zocca
LicenseGPL-3 (see LICENSE)
Maintainerzocca.marco gmail
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Sparse.Common

Contents

Description

 
Synopsis

Documentation

type Rows = Int #

type Cols = Int #

type IxRow = Int #

type IxCol = Int #

Lexicographic ordering types

type LexIx = Int #

data LexOrd #

Constructors

RowsFirst 
ColsFirst 
Instances
Eq LexOrd # 
Instance details

Defined in Data.Sparse.Types

Methods

(==) :: LexOrd -> LexOrd -> Bool #

(/=) :: LexOrd -> LexOrd -> Bool #

Show LexOrd # 
Instance details

Defined in Data.Sparse.Types

prd :: PrintDense a => a -> IO () #

Pretty-print with a descriptive header

prd0 :: PrintDense a => a -> IO () #

Pretty-print with no header

class PrintDense a #

Minimal complete definition

prd, prd0

Instances
PrintDense (SpVector Double) # 
Instance details

Defined in Data.Sparse.Common

Methods

prd :: SpVector Double -> IO () #

prd0 :: SpVector Double -> IO () #

PrintDense (SpVector (Complex Double)) # 
Instance details

Defined in Data.Sparse.Common

Methods

prd :: SpVector (Complex Double) -> IO () #

prd0 :: SpVector (Complex Double) -> IO () #

PrintDense (SpMatrix Double) # 
Instance details

Defined in Data.Sparse.Common

Methods

prd :: SpMatrix Double -> IO () #

prd0 :: SpMatrix Double -> IO () #

PrintDense (SpMatrix (Complex Double)) # 
Instance details

Defined in Data.Sparse.Common

Methods

prd :: SpMatrix (Complex Double) -> IO () #

prd0 :: SpMatrix (Complex Double) -> IO () #

newline :: IO () #

data PPrintOptions #

Pretty printing options: total length in of decimal digits

Constructors

PPOpts 
Instances
Eq PPrintOptions # 
Instance details

Defined in Data.Sparse.PPrint

Show PPrintOptions # 
Instance details

Defined in Data.Sparse.PPrint

printDN :: (PrintfArg a, Epsilon a, Ord a) => Int -> Int -> PPrintOptions -> [a] -> String #

Pretty print an array of real numbers

printCN :: (PrintfArg a, Epsilon a, Epsilon (Complex a), Ord a) => Int -> Int -> PPrintOptions -> [Complex a] -> String #

Pretty print an array of complex numbers

Misc. utilities

intersectWith :: Ord i => (a -> a -> b) -> [(i, a)] -> [(i, a)] -> [b] #

Intersection and union of sparse lists having indices in _ascending_ order

unionWith :: Ord i => (a -> a -> a) -> a -> [(i, a)] -> [(i, a)] -> [(i, a)] #

intersectWithD :: Ord i => (a -> a -> b) -> [(i, a)] -> [(i, a)] -> [b] #

Intersection of sparse lists having indices in _descending_ order

unionWithD :: Ord i => (a -> a -> a) -> a -> [(i, a)] -> [(i, a)] -> [(i, a)] #

Union of sparse lists having indices in _descending_ order

intersectWith0 :: (a -> b -> Ordering) -> (a -> b -> c) -> [a] -> [b] -> [c] #

unionWith0 :: (i -> i -> Ordering) -> (a -> a -> a) -> a -> [(i, a)] -> [(i, a)] -> [(i, a)] #

lift2snd :: (t -> t1 -> t2) -> (a, t) -> (a1, t1) -> t2 #

Lift a binary function onto the second entry of a tuple

safe :: (t -> Bool) -> (t -> a) -> t -> Maybe a #

Wrap a function with a null check, returning in Maybe

maxTup :: Ord t => (t, t) -> (t, t) -> (t, t) #

Componentwise tuple operations TODO : use semilattice properties instead

minTup :: Ord t => (t, t) -> (t, t) -> (t, t) #

Componentwise tuple operations TODO : use semilattice properties instead

indexed :: [b] -> [(Int, b)] #

integer-indexed ziplist

indexed' :: Int -> [a] -> [(Int, a)] #

indexed2 :: Int -> [c] -> [(Int, Int, c)] #

", 2d arrays

foldrMap :: (Foldable t, Functor t) => (a -> b) -> (b -> c -> c) -> c -> t a -> c #

foldr over the results of a fmap

foldlStrict :: (a -> b -> a) -> a -> [b] -> a #

strict left fold

ifoldr :: Num i => (a -> b -> b) -> b -> (i -> c -> d -> a) -> c -> [d] -> b #

indexed right fold

Bounds checking

type LB = Int #

type UB = Int #

inBounds :: LB -> UB -> Int -> Bool #

inBounds2 :: (LB, UB) -> (Int, Int) -> Bool #

inBounds0 :: UB -> Int -> Bool #

inBounds02 :: (UB, UB) -> (Int, Int) -> Bool #

Safe indexing

head' :: Vector a -> Maybe a #

tail' :: Vector a -> Maybe (Vector a) #

insertRowWith :: (IxCol -> IxCol) -> SpMatrix a -> SpVector a -> Key -> SpMatrix a #

Insert row , using the provided row index transformation function

insertRow :: SpMatrix a -> SpVector a -> Key -> SpMatrix a #

Insert row

insertColWith :: (IxRow -> IxRow) -> SpMatrix a -> SpVector a -> IxCol -> SpMatrix a #

Insert column, using the provided row index transformation function

insertCol :: SpMatrix a -> SpVector a -> IxCol -> SpMatrix a #

Insert column

diagonalSM :: SpVector a -> SpMatrix a #

Fill the diagonal of a SpMatrix with the components of a SpVector

outerProdSV :: Num a => SpVector a -> SpVector a -> SpMatrix a #

Outer product

(><) :: Num a => SpVector a -> SpVector a -> SpMatrix a #

Outer product

toSV :: SpMatrix a -> SpVector a #

Demote (n x 1) or (1 x n) SpMatrix to SpVector

svToSM :: SpVector a -> SpMatrix a #

promote a SV to SM

lookupRowSM :: SpMatrix a -> IxRow -> Maybe (SpVector a) #

Lookup a row in a SpMatrix; returns an SpVector with the row, if this is non-empty

extractCol :: SpMatrix a -> IxCol -> SpVector a #

Extract jth column

extractRow :: SpMatrix a -> IxRow -> SpVector a #

Extract ith row

extractVectorDenseWith :: Num a => (Int -> (IxRow, IxCol)) -> SpMatrix a -> SpVector a #

Generic extraction function

extractRowDense :: Num a => SpMatrix a -> IxRow -> SpVector a #

Extract ith row (dense)

extractColDense :: Num a => SpMatrix a -> IxCol -> SpVector a #

Extract jth column

extractDiagDense :: Num a => SpMatrix a -> SpVector a #

Extract the diagonal

extractSubRow :: SpMatrix a -> IxRow -> (Int, Int) -> SpVector a #

extract row interval (all entries between columns j1 and j2, INCLUDED, are returned) extractSubRow :: SpMatrix a -> IxRow -> (IxCol, IxCol) -> SpVector a extractSubRow m i (j1, j2) = case lookupRowSM m i of Nothing -> zeroSV (ncols m) Just rv -> ifilterSV (j _ -> j >= j1 && j <= j2) rv

", returning in Maybe extractSubRow :: SpMatrix a -> IxRow -> (Int, Int) -> Maybe (SpVector a) extractSubRow m i (j1, j2) = resizeSV (j2 - j1) . ifilterSV (j _ -> j >= j1 && j j2) <$ lookupRowSM m i

Extract an interval of SpVector components, changing accordingly the resulting SpVector size. Keys are _not_ rebalanced, i.e. components are still labeled according with respect to the source matrix.

extractSubCol :: SpMatrix a -> IxCol -> (IxRow, IxRow) -> SpVector a #

extract column interval

extractSubRow_RK :: SpMatrix a -> IxRow -> (IxCol, IxCol) -> SpVector a #

extract row interval, rebalance keys by subtracting lowest one

extractSubCol_RK :: SpMatrix a -> IxCol -> (IxRow, IxRow) -> SpVector a #

extract column interval, rebalance keys by subtracting lowest one

fromRowsL :: [SpVector a] -> SpMatrix a #

Pack a list of SpVectors as rows of an SpMatrix

fromRowsV :: Vector (SpVector a) -> SpMatrix a #

Pack a V.Vector of SpVectors as rows of an SpMatrix

fromColsV :: Vector (SpVector a) -> SpMatrix a #

Pack a V.Vector of SpVectors as columns of an SpMatrix

fromColsL :: [SpVector a] -> SpMatrix a #

Pack a list of SpVectors as columns an SpMatrix

toRowsL :: SpMatrix a -> [SpVector a] #

Unpack the rows of an SpMatrix into a list of SpVectors

toColsL :: SpMatrix a -> [SpVector a] #

Unpack the columns of an SpMatrix into a list of SpVectors

Orphan instances

PrintDense (SpVector Double) # 
Instance details

Methods

prd :: SpVector Double -> IO () #

prd0 :: SpVector Double -> IO () #

PrintDense (SpVector (Complex Double)) # 
Instance details

Methods

prd :: SpVector (Complex Double) -> IO () #

prd0 :: SpVector (Complex Double) -> IO () #

PrintDense (SpMatrix Double) # 
Instance details

Methods

prd :: SpMatrix Double -> IO () #

prd0 :: SpMatrix Double -> IO () #

PrintDense (SpMatrix (Complex Double)) # 
Instance details

Methods

prd :: SpMatrix (Complex Double) -> IO () #

prd0 :: SpMatrix (Complex Double) -> IO () #

(InnerSpace t, Scalar t ~ t) => LinearVectorSpace (SpVector t) # 
Instance details

Associated Types

type MatrixType (SpVector t) :: * #