Safe Haskell | Safe-Infered |
---|
- ·· :: Num α => IntMap α -> IntMap α -> α
- shiftKeys :: Int -> IntMap α -> IntMap α
- addElem :: Maybe α -> Int -> IntMap α -> IntMap α
- delElem :: Int -> IntMap α -> IntMap α
- partitionMap :: (α -> Bool) -> IntMap α -> (IntMap α, IntMap α)
- type Index = Int
- type SVec α = IntMap α
- data SparseVector α = SV {}
- setLength :: Int -> SparseVector α -> SparseVector α
- emptyVec :: SparseVector α
- zeroVec :: Int -> SparseVector α
- isZeroVec, isNotZeroVec :: SparseVector α -> Bool
- singVec :: (Eq α, Num α) => α -> SparseVector α
- (.>) :: (Eq α, Num α) => α -> SparseVector α -> SparseVector α
- partitionVec :: Num α => (α -> Bool) -> SparseVector α -> (SparseVector α, SparseVector α)
- (!) :: Num α => SparseVector α -> Index -> α
- eraseInVec :: Num α => SparseVector α -> Index -> SparseVector α
- vecIns :: (Eq t, Num t) => SparseVector t -> (Index, t) -> SparseVector t
- fillVec :: Num α => SparseVector α -> [α]
- sparseList :: (Num α, Eq α) => [α] -> SparseVector α
- showSparseList :: (Show α, Eq α, Num α) => [α] -> String
- showNonZero :: (Eq a, Num a, Show a) => a -> [Char]
- dot :: (Eq α, Num α) => SparseVector α -> SparseVector α -> α
- · :: (Eq α, Num α) => SparseVector α -> SparseVector α -> α
Documentation
addElem :: Maybe α -> Int -> IntMap α -> IntMap αSource
Adds element to the map at given index, shifting all keys after it
delElem :: Int -> IntMap α -> IntMap αSource
Deletes element of the map at given index, shifting all keys after it
partitionMap :: (α -> Bool) -> IntMap α -> (IntMap α, IntMap α)Source
Splits map using predicate and returns a pair with filtered map and re-enumereted second part (that doesn't satisfy predicate). For example:
>>>
partitionMap (>0) (fromList [(1,1),(2,-1),(3,-2),(4,3),(5,-4)])
( fromList [(1,1),(4,3)], fromList [(1,-1),(2,-2),(3,-4)] )
data SparseVector α Source
Sparse vector is just indexed map of non-zero values
Functor SparseVector |
|
Foldable SparseVector | fold functions are applied to non-zero values |
Eq α => Eq (SparseVector α) | |
(Eq α, Num α) => Num (SparseVector α) |
|
(Show α, Eq α, Num α) => Show (SparseVector α) | Shows size and filled vector (but without zeroes) |
Monoid (SparseVector α) | Monoid |
setLength :: Int -> SparseVector α -> SparseVector αSource
Sets vector's size
emptyVec :: SparseVector αSource
Vector of zero size with no values
zeroVec :: Int -> SparseVector αSource
Vector of given size with no non-zero values
isZeroVec, isNotZeroVec :: SparseVector α -> BoolSource
Checks if vector has no non-zero values (i.e. is empty)
singVec :: (Eq α, Num α) => α -> SparseVector αSource
Vector of length 1 with given value
(.>) :: (Eq α, Num α) => α -> SparseVector α -> SparseVector αSource
This is like cons (:
) operator for lists.
x .> v = singVec x <> v
partitionVec :: Num α => (α -> Bool) -> SparseVector α -> (SparseVector α, SparseVector α)Source
Splits vector using predicate and returns a pair with filtered values and re-enumereted second part (that doesn't satisfy predicate). For example:
>>>
partitionVec (>0) (sparseList [0,1,-1,2,3,0,-4,5,-6,0,7])
( sparseList [0,1,0,2,3,0,0,5,0,0,7], sparseList [-1,-4,-6] )
(!) :: Num α => SparseVector α -> Index -> αSource
Looks up an element in the vector (if not found, zero is returned)
eraseInVec :: Num α => SparseVector α -> Index -> SparseVector αSource
Deletes element of vector at given index (size of vector doesn't change)
vecIns :: (Eq t, Num t) => SparseVector t -> (Index, t) -> SparseVector tSource
fillVec :: Num α => SparseVector α -> [α]Source
Returns plain list with all zeroes restored
sparseList :: (Num α, Eq α) => [α] -> SparseVector αSource
Converts plain list to sparse vector, throwing out all zeroes
dot :: (Eq α, Num α) => SparseVector α -> SparseVector α -> αSource
Dot product of two sparse vectors
· :: (Eq α, Num α) => SparseVector α -> SparseVector α -> αSource
Unicode alias for dot