comfort-array-0.5.5: Arrays where the index type is a function of the shape type
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Array.Comfort.Storable

Synopsis

Documentation

data Array sh a Source #

Instances

Instances details
Block Array Source # 
Instance details

Defined in Data.Array.Comfort.Storable.Dim2

Methods

blockPrivate :: (C height, C width, Storable a) => Array (height, width) a -> BlockMatrix height width a

(AppendMonoid sh, Storable a) => Monoid (Array sh a) Source # 
Instance details

Defined in Data.Array.Comfort.Storable.Private

Methods

mempty :: Array sh a #

mappend :: Array sh a -> Array sh a -> Array sh a #

mconcat :: [Array sh a] -> Array sh a #

(AppendSemigroup sh, Storable a) => Semigroup (Array sh a) Source # 
Instance details

Defined in Data.Array.Comfort.Storable.Private

Methods

(<>) :: Array sh a -> Array sh a -> Array sh a #

sconcat :: NonEmpty (Array sh a) -> Array sh a #

stimes :: Integral b => b -> Array sh a -> Array sh a #

(C sh, Show sh, Storable a, Show a) => Show (Array sh a) Source # 
Instance details

Defined in Data.Array.Comfort.Storable.Private

Methods

showsPrec :: Int -> Array sh a -> ShowS #

show :: Array sh a -> String #

showList :: [Array sh a] -> ShowS #

NFData sh => NFData (Array sh a) Source # 
Instance details

Defined in Data.Array.Comfort.Storable.Private

Methods

rnf :: Array sh a -> () #

(C sh, Eq sh, Storable a, Eq a) => Eq (Array sh a) Source # 
Instance details

Defined in Data.Array.Comfort.Storable.Private

Methods

(==) :: Array sh a -> Array sh a -> Bool #

(/=) :: Array sh a -> Array sh a -> Bool #

shape :: Array sh a -> sh Source #

reshape :: (C sh0, C sh1) => sh1 -> Array sh0 a -> Array sh1 a Source #

mapShape :: (C sh0, C sh1) => (sh0 -> sh1) -> Array sh0 a -> Array sh1 a Source #

accessMaybe :: (Indexed sh, Storable a) => Array sh a -> Index sh -> Maybe a Source #

(!) :: (Indexed sh, Storable a) => Array sh a -> Index sh -> a infixl 9 Source #

toList :: (C sh, Storable a) => Array sh a -> [a] Source #

toAssociations :: (Indexed sh, Storable a) => Array sh a -> [(Index 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"

fromMap :: (Ord k, Storable a) => Map k a -> Array (Set k) a Source #

toMap :: (Ord k, Storable a) => Array (Set k) a -> Map k a Source #

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')

toRecord :: (Traversable f, Storable a) => Array (Record f) a -> f a Source #

fromContainer :: (C f, Storable a) => f a -> Array (Shape f) a Source #

toContainer :: (C f, Storable a) => Array (Shape f) a -> f a Source #

sample :: (Indexed sh, Storable a) => sh -> (Index sh -> a) -> Array sh a Source #

replicate :: (C sh, Storable a) => sh -> a -> Array sh a Source #

fromBoxed :: (C sh, Storable a) => Array sh a -> Array sh a Source #

toBoxed :: (C sh, Storable a) => Array sh a -> Array sh a Source #

toStorableVector :: (C sh, Storable a) => Array sh a -> Vector a Source #

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.

map :: (C sh, Storable a, Storable b) => (a -> b) -> Array sh a -> Array sh 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, Eq sh, Storable a, Storable b, Storable c) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c Source #

(//) :: (Indexed sh, Storable a) => Array sh a -> [(Index sh, a)] -> Array sh a Source #

accumulate :: (Indexed sh, Storable a) => (a -> b -> a) -> Array sh a -> [(Index sh, b)] -> Array sh a Source #

fromAssociations :: (Indexed sh, Storable a) => a -> sh -> [(Index sh, a)] -> 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.

singleton :: Storable a => a -> Array () a Source #

\x  ->  Array.singleton x ! () == (x::Word16)

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

takeRight :: (C sh0, C sh1, Storable a) => Array (sh0 ::+ sh1) a -> Array sh1 a Source #

split :: (C sh0, C sh1, Storable a) => Array (sh0 ::+ sh1) a -> (Array sh0 a, Array sh1 a) Source #

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 #

limits :: (C sh, Storable a, Ord a) => Array sh a -> (a, a) Source #

forAllNonEmpty $ \xs -> Array.limits xs ==? (Array.minimum xs, Array.maximum xs)

foldl :: (C sh, Storable a) => (b -> a -> b) -> b -> Array sh a -> b Source #

foldl1 :: (C sh, Storable a) => (a -> a -> a) -> Array sh a -> a Source #

foldMap :: (C sh, Storable a, Ord a, Semigroup m) => (a -> m) -> Array sh a -> m Source #