Safe Haskell | None |
---|---|
Language | Haskell2010 |
Signed integer version of dynamic word vectors.
See Data.Vector.Compact.WordVec for more details.
Note: for unsigned integers, you really should use WordVec
instead,
because that is significantly faster, and has much more specialized functions
implemented.
This module should be imported qualified (to avoid name clashes with Prelude).
Synopsis
- newtype IntVec = IntVec WordVec
- data Shape = Shape {}
- vecShape :: IntVec -> Shape
- vecLen :: IntVec -> Int
- vecBits :: IntVec -> Int
- showIntVec :: IntVec -> String
- showsPrecIntVec :: Int -> IntVec -> ShowS
- null :: IntVec -> Bool
- empty :: IntVec
- singleton :: Int -> IntVec
- isSingleton :: IntVec -> Maybe Int
- fromList :: [Int] -> IntVec
- fromList' :: (Int, (Int, Int)) -> [Int] -> IntVec
- fromList'' :: Shape -> [Int] -> IntVec
- lenMinMax :: [Int] -> (Int, (Int, Int))
- toList :: IntVec -> [Int]
- toRevList :: IntVec -> [Int]
- unsafeIndex :: Int -> IntVec -> Int
- safeIndex :: Int -> IntVec -> Maybe Int
- head :: IntVec -> Int
- tail :: IntVec -> IntVec
- cons :: Int -> IntVec -> IntVec
- uncons :: IntVec -> Maybe (Int, IntVec)
- last :: IntVec -> Int
- snoc :: IntVec -> Int -> IntVec
- concat :: IntVec -> IntVec -> IntVec
- fold :: (a -> Int -> a) -> a -> IntVec -> a
- naiveMap :: (Int -> Int) -> IntVec -> IntVec
- boundedMap :: (Int, Int) -> (Int -> Int) -> IntVec -> IntVec
- naiveZipWith :: (Int -> Int -> Int) -> IntVec -> IntVec -> IntVec
- boundedZipWith :: (Int, Int) -> (Int -> Int -> Int) -> IntVec -> IntVec -> IntVec
- listZipWith :: (Int -> Int -> a) -> IntVec -> IntVec -> [a]
- bitsNeededForMinMax :: (Int, Int) -> Int
- bitsNeededFor :: Int -> Int
- roundBits :: Int -> Int
The dynamic Word vector type
A dynamic int vector is a (small) vector of small signed integers stored compactly
The "shape" of a dynamic word vector
Show instance
showIntVec :: IntVec -> String Source #
Empty vector, singleton
Conversion to/from lists
fromList' :: (Int, (Int, Int)) -> [Int] -> IntVec Source #
usage: fromList' (len,(min,max)) xs
where min
and max
are the minimum and
maximum (or just a lower and upper bound) appearing in the list.
fromList'' :: Shape -> [Int] -> IntVec Source #
Don't use this unless you really know what you are doing!
lenMinMax :: [Int] -> (Int, (Int, Int)) Source #
Computes the length, minimum and maximum of a list, traversing it only once (instead of 3 times).
Indexing
Head, tail, etc
Generic operations
boundedMap :: (Int, Int) -> (Int -> Int) -> IntVec -> IntVec Source #
If you have (nearly sharp) lower and upper bounds for the result of your of function on your vector, mapping can be more efficient
boundedZipWith :: (Int, Int) -> (Int -> Int -> Int) -> IntVec -> IntVec -> IntVec Source #
If you have (nearly sharp) lower and upper bounds for the result of your of function on your vector, zipping can be more efficient
Number of bits needed
bitsNeededFor :: Int -> Int Source #
Note: this automatically rounds up to multiples of 4