Safe Haskell | Safe-Infered |
---|
- type SMx α = SVec (SVec α)
- data SparseMatrix α = SM {}
- height, width :: SparseMatrix α -> Int
- setSize :: Num α => (Int, Int) -> SparseMatrix α -> SparseMatrix α
- emptyMx :: SparseMatrix α
- zeroMx :: Num α => (Int, Int) -> SparseMatrix α
- isZeroVec, isNotZeroVec :: SparseVector α -> Bool
- isZeroMx, isNotZeroMx :: SparseMatrix α -> Bool
- idMx :: (Num α, Eq α) => Int -> SparseMatrix α
- addRow :: Num α => SparseVector α -> Index -> SparseMatrix α -> SparseMatrix α
- addCol :: Num α => SparseVector α -> Index -> SparseMatrix α -> SparseMatrix α
- addZeroRow :: Num α => Index -> SparseMatrix α -> SparseMatrix α
- addZeroCol :: Num α => Index -> SparseMatrix α -> SparseMatrix α
- delRow :: Num α => Index -> SparseMatrix α -> SparseMatrix α
- delCol :: Num α => Index -> SparseMatrix α -> SparseMatrix α
- delRowCol :: Num α => Index -> Index -> SparseMatrix α -> SparseMatrix α
- partitionMx :: Num α => (SparseVector α -> Bool) -> SparseMatrix α -> (SparseMatrix α, SparseMatrix α)
- separateMx :: Num α => (SparseVector α -> Bool) -> SparseMatrix α -> (SparseMatrix α, SparseMatrix α)
- (#) :: Num α => SparseMatrix α -> (Index, Index) -> α
- row :: Num α => SparseMatrix α -> Index -> SparseVector α
- col :: (Num α, Eq α) => SparseMatrix α -> Index -> SparseVector α
- updRow :: Num α => SparseMatrix α -> (SparseVector α -> SparseVector α) -> Index -> SparseMatrix α
- eraseRow :: Num α => SparseMatrix α -> Index -> SparseMatrix α
- erase :: Num α => SparseMatrix α -> (Index, Index) -> SparseMatrix α
- ins :: (Num α, Eq α) => SparseMatrix α -> ((Index, Index), α) -> SparseMatrix α
- findRowIndices :: (SparseVector α -> Bool) -> SparseMatrix α -> [Key]
- findRowIndicesR :: (SparseVector α -> Bool) -> SparseMatrix α -> [Key]
- diagonalMx :: (Num α, Eq α) => [α] -> SparseMatrix α
- fromRows :: Num α => [SparseVector α] -> SparseMatrix α
- toAssocList :: (Num α, Eq α) => SparseMatrix α -> [((Index, Index), α)]
- fromAssocList :: (Num α, Eq α) => [((Index, Index), α)] -> SparseMatrix α
- fillMx :: Num α => SparseMatrix α -> [[α]]
- sparseMx :: (Num α, Eq α) => [[α]] -> SparseMatrix α
- showSparseMatrix :: (Show α, Eq α, Num α) => [[α]] -> String
- column :: (Show α, Eq α, Num α) => [α] -> [String]
- trans :: (Num α, Eq α) => SparseMatrix α -> SparseMatrix α
- mulMV :: (Num α, Eq α) => SparseMatrix α -> SparseVector α -> SparseVector α
- (×·) :: (Num α, Eq α) => SparseMatrix α -> SparseVector α -> SparseVector α
- mulVM :: (Num α, Eq α) => SparseVector α -> SparseMatrix α -> SparseVector α
- ·× :: (Num α, Eq α) => SparseVector α -> SparseMatrix α -> SparseVector α
- mul :: (Num α, Eq α) => SparseMatrix α -> SparseMatrix α -> SparseMatrix α
- (×) :: (Num α, Eq α) => SparseMatrix α -> SparseMatrix α -> SparseMatrix α
Documentation
data SparseMatrix α Source
Sparse matrix is indexed map of non-zero rows,
Functor SparseMatrix |
|
Eq α => Eq (SparseMatrix α) | |
(Eq α, Num α) => Num (SparseMatrix α) | |
(Show α, Eq α, Num α) => Show (SparseMatrix α) | Shows size and filled matrix (but without zeroes) |
height, width :: SparseMatrix α -> IntSource
Matrix real height and width
setSize :: Num α => (Int, Int) -> SparseMatrix α -> SparseMatrix αSource
Sets height and width of matrix
emptyMx :: SparseMatrix αSource
Matrix of zero size with no values
isZeroVec, isNotZeroVec :: SparseVector α -> BoolSource
Checks if vector has no non-zero values (i.e. is empty)
isZeroMx, isNotZeroMx :: SparseMatrix α -> BoolSource
Checks if matrix has no non-zero values (i.e. is empty)
addRow :: Num α => SparseVector α -> Index -> SparseMatrix α -> SparseMatrix αSource
Adds row at given index, increasing matrix height by 1 and shifting indexes after it
addCol :: Num α => SparseVector α -> Index -> SparseMatrix α -> SparseMatrix αSource
Adds column at given index, increasing matrix width by 1 and shifting indexes after it
addZeroRow :: Num α => Index -> SparseMatrix α -> SparseMatrix αSource
Just adds zero row at given index
addZeroCol :: Num α => Index -> SparseMatrix α -> SparseMatrix αSource
Just adds zero column at given index
delRow :: Num α => Index -> SparseMatrix α -> SparseMatrix αSource
Deletes row at given index, decreasing matrix height by 1 and shifting indexes after it
delCol :: Num α => Index -> SparseMatrix α -> SparseMatrix αSource
Deletes column at given index, decreasing matrix width by 1 and shifting indexes after it
delRowCol :: Num α => Index -> Index -> SparseMatrix α -> SparseMatrix αSource
Deletes row and column at given indexes
partitionMx :: Num α => (SparseVector α -> Bool) -> SparseMatrix α -> (SparseMatrix α, SparseMatrix α)Source
Partitions matrix, using pedicate on rows and returns two new matrices, one constructed from rows satisfying predicate, and another from rows that don't
separateMx :: Num α => (SparseVector α -> Bool) -> SparseMatrix α -> (SparseMatrix α, SparseMatrix α)Source
(#) :: Num α => SparseMatrix α -> (Index, Index) -> αSource
Looks up an element in the matrix (if not found, zero is returned)
row :: Num α => SparseMatrix α -> Index -> SparseVector αSource
Returns row of matrix at given index
col :: (Num α, Eq α) => SparseMatrix α -> Index -> SparseVector αSource
Returns column of matrix at given index
updRow :: Num α => SparseMatrix α -> (SparseVector α -> SparseVector α) -> Index -> SparseMatrix αSource
Updates values in row using given function
eraseRow :: Num α => SparseMatrix α -> Index -> SparseMatrix αSource
Fills row with zeroes (i.e. deletes it, but size of matrix doesn't change)
erase :: Num α => SparseMatrix α -> (Index, Index) -> SparseMatrix αSource
Erases matrix element at given index
ins :: (Num α, Eq α) => SparseMatrix α -> ((Index, Index), α) -> SparseMatrix αSource
Inserts new element to the sparse matrix (replaces old value)
findRowIndices :: (SparseVector α -> Bool) -> SparseMatrix α -> [Key]Source
findRowIndicesR :: (SparseVector α -> Bool) -> SparseMatrix α -> [Key]Source
diagonalMx :: (Num α, Eq α) => [α] -> SparseMatrix αSource
Constructs square matrix with given elements on diagonal
fromRows :: Num α => [SparseVector α] -> SparseMatrix αSource
Constructs matrix from a list of rows
toAssocList :: (Num α, Eq α) => SparseMatrix α -> [((Index, Index), α)]Source
Converts sparse matrix to associative list, adding fake zero element, to save real size for inverse conversion
fromAssocList :: (Num α, Eq α) => [((Index, Index), α)] -> SparseMatrix αSource
Converts associative list to sparse matrix, using maximal index as matrix size
fillMx :: Num α => SparseMatrix α -> [[α]]Source
Converts sparse matrix to plain list-matrix with all zeroes restored
sparseMx :: (Num α, Eq α) => [[α]] -> SparseMatrix αSource
Converts plain list-matrix to sparse matrix, throwing out all zeroes
trans :: (Num α, Eq α) => SparseMatrix α -> SparseMatrix αSource
Transposes matrix (rows became columns)
mulMV :: (Num α, Eq α) => SparseMatrix α -> SparseVector α -> SparseVector αSource
Matrix-by-vector multiplication
(×·) :: (Num α, Eq α) => SparseMatrix α -> SparseVector α -> SparseVector αSource
Unicode alias for mulMV
mulVM :: (Num α, Eq α) => SparseVector α -> SparseMatrix α -> SparseVector αSource
Vector-by-matrix multiplication
·× :: (Num α, Eq α) => SparseVector α -> SparseMatrix α -> SparseVector αSource
Unicode alias for mulVM
mul :: (Num α, Eq α) => SparseMatrix α -> SparseMatrix α -> SparseMatrix αSource
Sparse matrices multiplication
(×) :: (Num α, Eq α) => SparseMatrix α -> SparseMatrix α -> SparseMatrix αSource
Unicode alias for mul