Safe Haskell | None |
---|---|
Language | Haskell98 |
The functions in this module miss any bound checking.
Synopsis
- data Array sh a = Array {
- shape :: sh
- buffer :: ForeignPtr a
- reshape :: sh1 -> Array sh0 a -> Array sh1 a
- mapShape :: (sh0 -> sh1) -> Array sh0 a -> Array sh1 a
- (!) :: (Indexed sh, Storable a) => Array sh a -> Index sh -> a
- unsafeCreate :: (C sh, Storable a) => sh -> (Ptr a -> IO ()) -> Array sh a
- unsafeCreateWithSize :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> Array sh a
- unsafeCreateWithSizeAndResult :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> (Array sh a, b)
- toList :: (C sh, Storable a) => Array sh a -> [a]
- fromList :: (C sh, Storable a) => sh -> [a] -> Array sh a
- vectorFromList :: Storable a => [a] -> Array (ZeroBased Int) a
- map :: (C sh, Storable a, Storable b) => (a -> b) -> Array sh a -> Array sh b
- mapWithIndex :: (Indexed sh, Index sh ~ ix, Storable a, Storable b) => (ix -> a -> b) -> Array sh a -> Array sh b
- zipWith :: (C sh, Storable a, Storable b, Storable c) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c
- (//) :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] -> Array sh a
- accumulate :: (Indexed sh, Storable a) => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a
- fromAssociations :: (Indexed sh, Storable a) => a -> sh -> [(Index sh, a)] -> Array sh a
- singleton :: Storable a => a -> Array () a
- append :: (C shx, C shy, Storable a) => Array shx a -> Array shy a -> Array (shx :+: shy) a
- take :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a
- drop :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a
- takeLeft :: (C sh0, C sh1, Storable a) => Array (sh0 :+: sh1) a -> Array sh0 a
- takeRight :: (C sh0, C sh1, Storable a) => Array (sh0 :+: sh1) a -> Array sh1 a
- split :: (C sh0, C sh1, Storable a) => Array (sh0 :+: sh1) a -> (Array sh0 a, Array sh1 a)
- takeCenter :: (C sh0, C sh1, C sh2, Storable a) => Array (sh0 :+: (sh1 :+: sh2)) a -> Array sh1 a
- sum :: (C sh, Storable a, Num a) => Array sh a -> a
- product :: (C sh, Storable a, Num a) => Array sh a -> a
- foldl :: (C sh, Storable a) => (b -> a -> b) -> b -> Array sh a -> b
Documentation
Array | |
|
unsafeCreateWithSizeAndResult :: (C sh, Storable a) => sh -> (Int -> Ptr a -> IO b) -> (Array sh a, b) Source #
mapWithIndex :: (Indexed sh, Index sh ~ ix, Storable a, Storable b) => (ix -> a -> b) -> Array sh a -> Array sh b Source #
zipWith :: (C sh, Storable a, Storable b, Storable c) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c Source #
accumulate :: (Indexed sh, Storable a) => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a Source #
append :: (C shx, C shy, Storable a) => Array shx a -> Array shy a -> Array (shx :+: shy) a Source #
take :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a Source #
\(QC.NonNegative n) (Array16 x) -> x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x))
drop :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a Source #
\(QC.NonNegative n) (Array16 x) -> x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x))
takeLeft :: (C sh0, C sh1, Storable a) => Array (sh0 :+: sh1) a -> Array sh0 a Source #
\(Array16 x) (Array16 y) -> let xy = Array.append x y in x == Array.takeLeft xy && y == Array.takeRight xy
takeCenter :: (C sh0, C sh1, C sh2, Storable a) => Array (sh0 :+: (sh1 :+: sh2)) a -> Array sh1 a Source #
\(Array16 x) (Array16 y) (Array16 z) -> let xyz = Array.append x $ Array.append y z in y == Array.takeCenter xyz
sum :: (C sh, Storable a, Num a) => Array sh a -> a Source #
\(Array16 xs) -> Array.sum xs == sum (Array.toList xs)