Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Synopsis
- data Array sh a
- shape :: Array sh a -> sh
- reshape :: (C sh0, C sh1) => sh1 -> Array sh0 a -> Array sh1 a
- mapShape :: (C sh0, C sh1) => (sh0 -> sh1) -> Array sh0 a -> Array sh1 a
- accessMaybe :: (Indexed sh, Storable a) => Array sh a -> Index sh -> Maybe a
- (!) :: (Indexed sh, Storable a) => Array sh a -> Index sh -> a
- toList :: (C sh, Storable a) => Array sh a -> [a]
- vectorFromList :: Storable a => [a] -> Array (ZeroBased Int) a
- toAssociations :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)]
- fromList :: (C sh, Storable a) => sh -> [a] -> Array sh a
- fromMap :: (Ord k, Storable a) => Map k a -> Array (Set k) a
- toMap :: (Ord k, Storable a) => Array (Set k) a -> Map k a
- fromIntMap :: Storable a => IntMap a -> Array IntSet a
- toIntMap :: Storable a => Array IntSet a -> IntMap a
- fromTuple :: (NestedTuple tuple, Storable a) => DataTuple tuple a -> Array (NestedTuple ixtype tuple) a
- toTuple :: (NestedTuple tuple, Storable a) => Array (NestedTuple ixtype tuple) a -> DataTuple tuple a
- fromRecord :: (Traversable f, Storable a) => f a -> Array (Record f) a
- toRecord :: (Traversable f, Storable a) => Array (Record f) a -> f a
- fromContainer :: (C f, Storable a) => f a -> Array (Shape f) a
- toContainer :: (C f, Storable a) => Array (Shape f) a -> f a
- sample :: (Indexed sh, Storable a) => sh -> (Index sh -> a) -> Array sh a
- replicate :: (C sh, Storable a) => sh -> a -> Array sh a
- fromBoxed :: (C sh, Storable a) => Array sh a -> Array sh a
- toBoxed :: (C sh, Storable a) => Array sh a -> Array sh a
- fromStorableVector :: Storable a => Vector a -> Array (ZeroBased Int) a
- toStorableVector :: (C sh, Storable a) => Array sh a -> Vector a
- fromBlockArray1 :: (Ord k, C shape, Storable a) => Array (Set k) (Array shape a) -> Array (Map k shape) a
- fromBlockArray2 :: (Ord row, C height, Eq height) => (Ord column, C width, Eq width) => Storable a => Map row height -> Map column width -> Array (Set row, Set column) (Array (height, width) a) -> Array (Map row height, Map column width) a
- fromNonEmptyBlockArray2 :: (Ord row, C height, Eq height) => (Ord column, C width, Eq width) => Storable a => Array (Set row, Set column) (Array (height, width) a) -> Array (Map row height, Map column width) 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, Eq 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
- pick :: (Indexed sh0, C sh1, Storable a) => Array (sh0, sh1) a -> Index sh0 -> Array sh1 a
- toRowArray :: (Indexed sh0, C sh1, Storable a) => Array (sh0, sh1) a -> Array sh0 (Array sh1 a)
- fromRowArray :: (C sh0, C sh1, Eq sh1, Storable a) => sh1 -> Array sh0 (Array sh1 a) -> Array (sh0, sh1) 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
- takeSet :: (Indexed sh, Index sh ~ ix, Ord ix, Storable a) => Set ix -> Array sh a -> Array (Set ix) a
- takeIntSet :: (Indexed sh, Index sh ~ Int, Storable a) => IntSet -> Array sh a -> Array IntSet a
- sum :: (C sh, Storable a, Num a) => Array sh a -> a
- product :: (C sh, Storable a, Num a) => Array sh a -> a
- minimum :: (C sh, Storable a, Ord a) => Array sh a -> a
- argMinimum :: (InvIndexed sh, Storable a, Ord a) => Array sh a -> (Index sh, a)
- maximum :: (C sh, Storable a, Ord a) => Array sh a -> a
- argMaximum :: (InvIndexed sh, Storable a, Ord a) => Array sh a -> (Index sh, a)
- limits :: (C sh, Storable a, Ord a) => Array sh a -> (a, a)
- foldl :: (C sh, Storable a) => (b -> a -> b) -> b -> Array sh a -> b
- foldl1 :: (C sh, Storable a) => (a -> a -> a) -> Array sh a -> a
- foldMap :: (C sh, Storable a, Ord a, Semigroup m) => (a -> m) -> Array sh a -> m
Documentation
Instances
Block Array Source # | |
Defined in Data.Array.Comfort.Storable.Dim2 blockPrivate :: (C height, C width, Storable a) => Array (height, width) a -> BlockMatrix height width a | |
(AppendMonoid sh, Storable a) => Monoid (Array sh a) Source # | |
(AppendSemigroup sh, Storable a) => Semigroup (Array sh a) Source # | |
(C sh, Show sh, Storable a, Show a) => Show (Array sh a) Source # | |
NFData sh => NFData (Array sh a) Source # | |
Defined in Data.Array.Comfort.Storable.Private | |
(C sh, Eq sh, Storable a, Eq a) => Eq (Array sh a) Source # | |
fromList :: (C sh, Storable a) => sh -> [a] -> Array sh a Source #
>>>
Array.fromList (shapeInt 5) ['a'..]
StorableArray.fromList (ZeroBased {zeroBasedSize = 5}) "abcde"
fromTuple :: (NestedTuple tuple, Storable a) => DataTuple tuple a -> Array (NestedTuple ixtype tuple) a Source #
>>>
Array.fromTuple ('a',('b','c')) :: Array (Shape.NestedTuple Shape.TupleIndex (X,(X,X))) Char
StorableArray.fromList (NestedTuple {getNestedTuple = (Element 0,(Element 1,Element 2))}) "abc"
>>>
let arr :: Array (Shape.NestedTuple Shape.TupleAccessor (X,(X,X))) Char arr = Array.fromTuple ('a',('b','c')) in (arr ! fst, arr ! (fst.snd))
('a','b')
toTuple :: (NestedTuple tuple, Storable a) => Array (NestedTuple ixtype tuple) a -> DataTuple tuple a Source #
fromRecord :: (Traversable f, Storable a) => f a -> Array (Record f) a Source #
>>>
let arr = Array.fromRecord ('a' :+ 'b') in let (real:+imag) = Shape.indexRecordFromShape $ Array.shape arr in (arr ! real, arr ! imag)
('a','b')
fromBlockArray1 :: (Ord k, C shape, Storable a) => Array (Set k) (Array shape a) -> Array (Map k shape) a Source #
Deprecated: Use fromBlockArray instead.
fromBlockArray2 :: (Ord row, C height, Eq height) => (Ord column, C width, Eq width) => Storable a => Map row height -> Map column width -> Array (Set row, Set column) (Array (height, width) a) -> Array (Map row height, Map column width) a Source #
Deprecated: Use Storable.Dim2.fromBlockArray instead.
fromNonEmptyBlockArray2 :: (Ord row, C height, Eq height) => (Ord column, C width, Eq width) => Storable a => Array (Set row, Set column) (Array (height, width) a) -> Array (Map row height, Map column width) a Source #
Deprecated: Use Storable.Dim2.fromNonEmptyBlockArray instead.
mapWithIndex :: (Indexed sh, Index sh ~ ix, Storable a, Storable b) => (ix -> a -> b) -> Array sh a -> Array sh b Source #
zipWith :: (C sh, Eq 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 #
pick :: (Indexed sh0, C sh1, Storable a) => Array (sh0, sh1) a -> Index sh0 -> Array sh1 a Source #
Deprecated: Use Storable.Dim2.takeRow instead.
toRowArray :: (Indexed sh0, C sh1, Storable a) => Array (sh0, sh1) a -> Array sh0 (Array sh1 a) Source #
Deprecated: Use Storable.Dim2.toRowArray instead.
fromRowArray :: (C sh0, C sh1, Eq sh1, Storable a) => sh1 -> Array sh0 (Array sh1 a) -> Array (sh0, sh1) a Source #
Deprecated: Use Storable.Dim2.fromRowArray instead.
append :: (C shx, C shy, Storable a) => Array shx a -> Array shy a -> Array (shx ::+ shy) a infixr 5 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
takeSet :: (Indexed sh, Index sh ~ ix, Ord ix, Storable a) => Set ix -> Array sh a -> Array (Set ix) a Source #
>>>
Array.takeSet (Set.fromList [0,2,4,7,13]) (Array.vectorFromList [3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3::Word8])
StorableArray... (... [0,2,4,7,13]) [3,4,5,6,7]
takeIntSet :: (Indexed sh, Index sh ~ Int, Storable a) => IntSet -> Array sh a -> Array IntSet a Source #
>>>
Array.takeIntSet (IntSet.fromList [0,2,4,7,13]) (Array.vectorFromList [3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3::Word8])
StorableArray... (... [0,2,4,7,13]) [3,4,5,6,7]
sum :: (C sh, Storable a, Num a) => Array sh a -> a Source #
\(Array16 xs) -> Array.sum xs == sum (Array.toList xs)
product :: (C sh, Storable a, Num a) => Array sh a -> a Source #
\(Array16 xs) -> Array.product xs == product (Array.toList xs)
minimum :: (C sh, Storable a, Ord a) => Array sh a -> a Source #
It is a checked error if the vector is empty.
forAllNonEmpty $ \xs -> Array.minimum xs ==? minimum (Array.toList xs)
argMinimum :: (InvIndexed sh, Storable a, Ord a) => Array sh a -> (Index sh, a) Source #
maximum :: (C sh, Storable a, Ord a) => Array sh a -> a Source #
It is a checked error if the vector is empty.
forAllNonEmpty $ \xs -> Array.maximum xs ==? maximum (Array.toList xs)
argMaximum :: (InvIndexed sh, Storable a, Ord a) => Array sh a -> (Index sh, a) Source #