Copyright | (c) Alexey Kuleshevich 2020 |
---|---|
License | BSD3 |
Maintainer | Alexey Kuleshevich <lehins@yandex.ru> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- type Vector r e = Array r Ix1 e
- type MVector s r e = MArray s r Ix1 e
- slength :: Stream r ix e => Array r ix e -> Maybe Sz1
- maxSize :: Load r ix e => Array r ix e -> Maybe (Sz ix)
- size :: Load r ix e => Array r ix e -> Sz ix
- snull :: Load r ix e => Array r ix e -> Bool
- (!?) :: (Manifest r ix e, MonadThrow m) => Array r ix e -> ix -> m e
- (!) :: Manifest r ix e => Array r ix e -> ix -> e
- index :: Manifest r ix e => Array r ix e -> ix -> Maybe e
- index' :: Manifest r ix e => Array r ix e -> ix -> e
- head' :: Source r Ix1 e => Vector r e -> e
- shead' :: Stream r Ix1 e => Vector r e -> e
- last' :: Source r Ix1 e => Vector r e -> e
- indexM :: (Manifest r ix e, MonadThrow m) => Array r ix e -> ix -> m e
- headM :: (Source r Ix1 e, MonadThrow m) => Vector r e -> m e
- sheadM :: (Stream r Ix1 e, MonadThrow m) => Vector r e -> m e
- lastM :: (Source r Ix1 e, MonadThrow m) => Vector r e -> m e
- unconsM :: (MonadThrow m, Source r Ix1 e) => Vector r e -> m (e, Vector D e)
- unsnocM :: (MonadThrow m, Source r Ix1 e) => Vector r e -> m (Vector D e, e)
- slice :: Source r Ix1 e => Ix1 -> Sz1 -> Vector r e -> Vector r e
- slice' :: Source r Ix1 e => Ix1 -> Sz1 -> Vector r e -> Vector r e
- sliceM :: (Source r Ix1 e, MonadThrow m) => Ix1 -> Sz1 -> Vector r e -> m (Vector r e)
- sslice :: Stream r Ix1 e => Ix1 -> Sz1 -> Vector r e -> Vector DS e
- sliceAt :: Source r Ix1 e => Sz1 -> Vector r e -> (Vector r e, Vector r e)
- sliceAt' :: Source r Ix1 e => Sz1 -> Vector r e -> (Vector r e, Vector r e)
- sliceAtM :: (Source r Ix1 e, MonadThrow m) => Sz1 -> Vector r e -> m (Vector r e, Vector r e)
- init :: Source r Ix1 e => Vector r e -> Vector r e
- init' :: Source r Ix1 e => Vector r e -> Vector r e
- initM :: (Source r Ix1 e, MonadThrow m) => Vector r e -> m (Vector r e)
- tail :: Source r Ix1 e => Vector r e -> Vector r e
- tail' :: Source r Ix1 e => Vector r e -> Vector r e
- tailM :: (Source r Ix1 e, MonadThrow m) => Vector r e -> m (Vector r e)
- take :: Source r Ix1 e => Sz1 -> Vector r e -> Vector r e
- take' :: Source r Ix1 e => Sz1 -> Vector r e -> Vector r e
- takeM :: (Source r Ix1 e, MonadThrow m) => Sz1 -> Vector r e -> m (Vector r e)
- stake :: Stream r Ix1 e => Sz1 -> Vector r e -> Vector DS e
- drop :: Source r Ix1 e => Sz1 -> Vector r e -> Vector r e
- drop' :: Source r Ix1 e => Sz1 -> Vector r e -> Vector r e
- dropM :: (Source r Ix1 e, MonadThrow m) => Sz1 -> Vector r e -> m (Vector r e)
- sdrop :: Stream r Ix1 e => Sz1 -> Vector r e -> Vector DS e
- empty :: forall r ix e. Construct r ix e => Array r ix e
- sempty :: Vector DS e
- singleton :: forall r ix e. Construct r ix e => e -> Array r ix e
- ssingleton :: e -> Vector DS e
- cons :: e -> Vector DL e -> Vector DL e
- snoc :: Vector DL e -> e -> Vector DL e
- replicate :: forall ix e. Index ix => Comp -> Sz ix -> e -> Array DL ix e
- sreplicate :: Sz1 -> e -> Vector DS e
- generate :: Comp -> Sz1 -> (Ix1 -> e) -> Vector D e
- sgenerate :: Sz1 -> (Ix1 -> e) -> Vector DS e
- siterate :: (e -> e) -> e -> Vector DS e
- siterateN :: Sz1 -> (e -> e) -> e -> Vector DS e
- sreplicateM :: Monad m => Sz1 -> m e -> m (Vector DS e)
- sgenerateM :: Monad m => Sz1 -> (Ix1 -> m e) -> m (Vector DS e)
- siterateNM :: Monad m => Sz1 -> (e -> m e) -> e -> m (Vector DS e)
- sunfoldr :: (s -> Maybe (e, s)) -> s -> Vector DS e
- sunfoldrM :: Monad m => (s -> m (Maybe (e, s))) -> s -> m (Vector DS e)
- sunfoldrN :: Sz1 -> (s -> Maybe (e, s)) -> s -> Vector DS e
- sunfoldrNM :: Monad m => Sz1 -> (s -> m (Maybe (e, s))) -> s -> m (Vector DS e)
- sunfoldrExactN :: Sz1 -> (s -> (e, s)) -> s -> Vector DS e
- sunfoldrExactNM :: Monad m => Sz1 -> (s -> m (e, s)) -> s -> m (Vector DS e)
- (...) :: Index ix => ix -> ix -> Array D ix ix
- (..:) :: Index ix => ix -> ix -> Array D ix ix
- enumFromN :: Num e => Comp -> e -> Sz1 -> Vector D e
- senumFromN :: Num e => e -> Sz1 -> Vector DS e
- enumFromStepN :: Num e => Comp -> e -> e -> Sz1 -> Vector D e
- senumFromStepN :: Num e => e -> e -> Sz1 -> Vector DS e
- sappend :: (Stream r1 Ix1 e, Stream r2 Ix1 e) => Vector r1 e -> Vector r2 e -> Vector DS e
- sconcat :: Stream r Ix1 e => [Vector r e] -> Vector DS e
- smap :: Stream r ix a => (a -> b) -> Array r ix a -> Vector DS b
- simap :: Stream r ix a => (ix -> a -> b) -> Array r ix a -> Vector DS b
- straverse :: (Stream r ix a, Applicative f) => (a -> f b) -> Array r ix a -> f (Vector DS b)
- sitraverse :: (Stream r ix a, Applicative f) => (ix -> a -> f b) -> Array r ix a -> f (Vector DS b)
- smapM :: (Stream r ix a, Monad m) => (a -> m b) -> Array r ix a -> m (Vector DS b)
- smapM_ :: (Stream r ix a, Monad m) => (a -> m b) -> Array r ix a -> m ()
- simapM :: (Stream r ix a, Monad m) => (ix -> a -> m b) -> Array r ix a -> m (Vector DS b)
- simapM_ :: (Stream r ix a, Monad m) => (ix -> a -> m b) -> Array r ix a -> m ()
- sforM :: (Stream r ix a, Monad m) => Array r ix a -> (a -> m b) -> m (Vector DS b)
- sforM_ :: (Stream r ix a, Monad m) => Array r ix a -> (a -> m b) -> m ()
- siforM :: (Stream r ix a, Monad m) => Array r ix a -> (ix -> a -> m b) -> m (Vector DS b)
- siforM_ :: (Stream r ix a, Monad m) => Array r ix a -> (ix -> a -> m b) -> m ()
- szip :: (Stream ra Ix1 a, Stream rb Ix1 b) => Vector ra a -> Vector rb b -> Vector DS (a, b)
- szip3 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c) => Vector ra a -> Vector rb b -> Vector rc c -> Vector DS (a, b, c)
- szip4 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d) => Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector DS (a, b, c, d)
- szip5 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e) => Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector DS (a, b, c, d, e)
- szip6 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f) => Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> Vector DS (a, b, c, d, e, f)
- szipWith :: (Stream ra Ix1 a, Stream rb Ix1 b) => (a -> b -> c) -> Vector ra a -> Vector rb b -> Vector DS c
- szipWith3 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c) => (a -> b -> c -> d) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector DS d
- szipWith4 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d) => (a -> b -> c -> d -> e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector DS e
- szipWith5 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e) => (a -> b -> c -> d -> e -> f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector DS f
- szipWith6 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f) => (a -> b -> c -> d -> e -> f -> g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> Vector DS g
- sizipWith :: (Stream ra Ix1 a, Stream rb Ix1 b) => (Ix1 -> a -> b -> c) -> Vector ra a -> Vector rb b -> Vector DS c
- sizipWith3 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c) => (Ix1 -> a -> b -> c -> d) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector DS d
- sizipWith4 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d) => (Ix1 -> a -> b -> c -> d -> e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector DS e
- sizipWith5 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e) => (Ix1 -> a -> b -> c -> d -> e -> f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector DS f
- sizipWith6 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f) => (Ix1 -> a -> b -> c -> d -> e -> f -> g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> Vector DS g
- szipWithM :: (Stream ra Ix1 a, Stream rb Ix1 b, Monad m) => (a -> b -> m c) -> Vector ra a -> Vector rb b -> m (Vector DS c)
- szipWith3M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Monad m) => (a -> b -> c -> m d) -> Vector ra a -> Vector rb b -> Vector rc c -> m (Vector DS d)
- szipWith4M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Monad m) => (a -> b -> c -> d -> m e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> m (Vector DS e)
- szipWith5M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Monad m) => (a -> b -> c -> d -> e -> m f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> m (Vector DS f)
- szipWith6M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f, Monad m) => (a -> b -> c -> d -> e -> f -> m g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> m (Vector DS g)
- sizipWithM :: (Stream ra Ix1 a, Stream rb Ix1 b, Monad m) => (Ix1 -> a -> b -> m c) -> Vector ra a -> Vector rb b -> m (Vector DS c)
- sizipWith3M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Monad m) => (Ix1 -> a -> b -> c -> m d) -> Vector ra a -> Vector rb b -> Vector rc c -> m (Vector DS d)
- sizipWith4M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Monad m) => (Ix1 -> a -> b -> c -> d -> m e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> m (Vector DS e)
- sizipWith5M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Monad m) => (Ix1 -> a -> b -> c -> d -> e -> m f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> m (Vector DS f)
- sizipWith6M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f, Monad m) => (Ix1 -> a -> b -> c -> d -> e -> f -> m g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> m (Vector DS g)
- szipWithM_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Monad m) => (a -> b -> m c) -> Vector ra a -> Vector rb b -> m ()
- szipWith3M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Monad m) => (a -> b -> c -> m d) -> Vector ra a -> Vector rb b -> Vector rc c -> m ()
- szipWith4M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Monad m) => (a -> b -> c -> d -> m e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> m ()
- szipWith5M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Monad m) => (a -> b -> c -> d -> e -> m f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> m ()
- szipWith6M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f, Monad m) => (a -> b -> c -> d -> e -> f -> m g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> m ()
- sizipWithM_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Monad m) => (Ix1 -> a -> b -> m c) -> Vector ra a -> Vector rb b -> m ()
- sizipWith3M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Monad m) => (Ix1 -> a -> b -> c -> m d) -> Vector ra a -> Vector rb b -> Vector rc c -> m ()
- sizipWith4M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Monad m) => (Ix1 -> a -> b -> c -> d -> m e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> m ()
- sizipWith5M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Monad m) => (Ix1 -> a -> b -> c -> d -> e -> m f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> m ()
- sizipWith6M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f, Monad m) => (Ix1 -> a -> b -> c -> d -> e -> f -> m g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> m ()
- sfilter :: Stream r ix e => (e -> Bool) -> Array r ix e -> Vector DS e
- sifilter :: Stream r ix a => (ix -> a -> Bool) -> Array r ix a -> Vector DS a
- sfilterM :: (Stream r ix e, Applicative f) => (e -> f Bool) -> Array r ix e -> f (Vector DS e)
- sifilterM :: (Stream r ix a, Applicative f) => (ix -> a -> f Bool) -> Array r ix a -> f (Vector DS a)
- smapMaybe :: Stream r ix a => (a -> Maybe b) -> Array r ix a -> Vector DS b
- smapMaybeM :: (Stream r ix a, Applicative f) => (a -> f (Maybe b)) -> Array r ix a -> f (Vector DS b)
- scatMaybes :: Stream r ix (Maybe a) => Array r ix (Maybe a) -> Vector DS a
- simapMaybe :: Stream r ix a => (ix -> a -> Maybe b) -> Array r ix a -> Vector DS b
- simapMaybeM :: (Stream r ix a, Applicative f) => (ix -> a -> f (Maybe b)) -> Array r ix a -> f (Vector DS b)
- sfoldl :: Stream r ix e => (a -> e -> a) -> a -> Array r ix e -> a
- sfoldlM :: (Stream r ix e, Monad m) => (a -> e -> m a) -> a -> Array r ix e -> m a
- sfoldlM_ :: (Stream r ix e, Monad m) => (a -> e -> m a) -> a -> Array r ix e -> m ()
- sifoldl :: Stream r ix e => (a -> ix -> e -> a) -> a -> Array r ix e -> a
- sifoldlM :: (Stream r ix e, Monad m) => (a -> ix -> e -> m a) -> a -> Array r ix e -> m a
- sifoldlM_ :: (Stream r ix e, Monad m) => (a -> ix -> e -> m a) -> a -> Array r ix e -> m ()
- sfoldl1' :: Stream r ix e => (e -> e -> e) -> Array r ix e -> e
- sfoldl1M :: (Stream r ix e, MonadThrow m) => (e -> e -> m e) -> Array r ix e -> m e
- sfoldl1M_ :: (Stream r ix e, MonadThrow m) => (e -> e -> m e) -> Array r ix e -> m ()
- sor :: Stream r ix Bool => Array r ix Bool -> Bool
- sand :: Stream r ix Bool => Array r ix Bool -> Bool
- sall :: Stream r ix e => (e -> Bool) -> Array r ix e -> Bool
- sany :: Stream r ix e => (e -> Bool) -> Array r ix e -> Bool
- ssum :: (Num e, Stream r ix e) => Array r ix e -> e
- sproduct :: (Num e, Stream r ix e) => Array r ix e -> e
- smaximum' :: (Ord e, Stream r ix e) => Array r ix e -> e
- smaximumM :: (Ord e, Stream r ix e, MonadThrow m) => Array r ix e -> m e
- sminimum' :: (Ord e, Stream r ix e) => Array r ix e -> e
- sminimumM :: (Ord e, Stream r ix e, MonadThrow m) => Array r ix e -> m e
- stoList :: Stream r ix e => Array r ix e -> [e]
- fromList :: forall r e. Mutable r Ix1 e => Comp -> [e] -> Array r Ix1 e
- sfromList :: [e] -> Vector DS e
- sfromListN :: Sz1 -> [e] -> Vector DS e
- compute :: forall r ix e r'. (Mutable r ix e, Load r' ix e) => Array r' ix e -> Array r ix e
- computeS :: forall r ix e r'. (Mutable r ix e, Load r' ix e) => Array r' ix e -> Array r ix e
- computeIO :: forall r ix e r' m. (Mutable r ix e, Load r' ix e, MonadIO m) => Array r' ix e -> m (Array r ix e)
- computePrimM :: forall r ix e r' m. (Mutable r ix e, Load r' ix e, PrimMonad m) => Array r' ix e -> m (Array r ix e)
- computeAs :: (Mutable r ix e, Load r' ix e) => r -> Array r' ix e -> Array r ix e
- computeProxy :: (Mutable r ix e, Load r' ix e) => proxy r -> Array r' ix e -> Array r ix e
- computeSource :: forall r ix e r'. (Mutable r ix e, Source r' ix e) => Array r' ix e -> Array r ix e
- computeWithStride :: forall r ix e r'. (Mutable r ix e, StrideLoad r' ix e) => Stride ix -> Array r' ix e -> Array r ix e
- computeWithStrideAs :: (Mutable r ix e, StrideLoad r' ix e) => r -> Stride ix -> Array r' ix e -> Array r ix e
- clone :: Mutable r ix e => Array r ix e -> Array r ix e
- convert :: forall r ix e r'. (Mutable r ix e, Load r' ix e) => Array r' ix e -> Array r ix e
- convertAs :: (Mutable r ix e, Load r' ix e) => r -> Array r' ix e -> Array r ix e
- convertProxy :: (Mutable r ix e, Load r' ix e) => proxy r -> Array r' ix e -> Array r ix e
- takeS :: Stream r ix e => Sz1 -> Array r ix e -> Array DS Ix1 e
- dropS :: Stream r ix e => Sz1 -> Array r ix e -> Array DS Ix1 e
- unfoldr :: (s -> Maybe (e, s)) -> s -> Vector DS e
- unfoldrN :: Sz1 -> (s -> Maybe (e, s)) -> s -> Vector DS e
- filterS :: Stream r ix e => (e -> Bool) -> Array r ix e -> Array DS Ix1 e
- ifilterS :: Source r ix a => (ix -> a -> Bool) -> Array r ix a -> Array DS Ix1 a
- filterM :: (Stream r ix e, Applicative f) => (e -> f Bool) -> Array r ix e -> f (Vector DS e)
- ifilterM :: (Source r ix a, Applicative f) => (ix -> a -> f Bool) -> Array r ix a -> f (Array DS Ix1 a)
- mapMaybeS :: Stream r ix a => (a -> Maybe b) -> Array r ix a -> Vector DS b
- imapMaybeS :: Source r ix a => (ix -> a -> Maybe b) -> Array r ix a -> Array DS Ix1 b
- mapMaybeM :: (Stream r ix a, Applicative f) => (a -> f (Maybe b)) -> Array r ix a -> f (Vector DS b)
- imapMaybeM :: (Source r ix a, Applicative f) => (ix -> a -> f (Maybe b)) -> Array r ix a -> f (Array DS Ix1 b)
- catMaybesS :: Stream r ix (Maybe a) => Array r ix (Maybe a) -> Vector DS a
- traverseS :: (Stream r ix a, Applicative f) => (a -> f b) -> Array r ix a -> f (Vector DS b)
- module Data.Massiv.Core
- module Data.Massiv.Array.Delayed
- module Data.Massiv.Array.Manifest
- module Data.Massiv.Array.Mutable
Documentation
type Vector r e = Array r Ix1 e Source #
Type synonym for a single dimension array, or simply a flat vector.
Since: 0.5.0
type MVector s r e = MArray s r Ix1 e Source #
Type synonym for a single dimension mutable array, or simply a flat mutable vector.
Since: 0.5.0
Accessors
Size
slength :: Stream r ix e => Array r ix e -> Maybe Sz1 Source #
O(1) - Get the length of a Stream
array, but only if it is known exactly in
constant time without looking at any of the elements in the array.
Related: maxSize
, size
, elemsCount
and totalElem
Examples
>>>
slength $ sfromList []
Nothing>>>
slength $ sreplicate 5 ()
Just (Sz1 5)>>>
slength $ makeArrayLinearR D Seq (Sz1 5) id
Just (Sz1 5)>>>
slength $ sunfoldr (\x -> Just (x, x)) (0 :: Int)
Nothing>>>
slength $ sunfoldrN 10 (\x -> Just (x, x)) (0 :: Int)
Nothing>>>
slength $ sunfoldrExactN 10 (\x -> (x, x)) (0 :: Int)
Just (Sz1 10)
Similar:
Data.Foldable.
length
- For some data structures, like a list for
example, it is an O(n) operation, because there is a need to evaluate the full spine
and possibly even the elements in order to get the full length. With
Stream
vectors that is rarely the case. Data.Vector.Generic.
length
- In the vector package this function will always break fusion, unless it is the only operation that is applied to the vector.
Since: 0.5.0
maxSize :: Load r ix e => Array r ix e -> Maybe (Sz ix) Source #
O(1) - Get the possible maximum size of an immutabe array. If the lookup of size
in constant time is not possible, Nothing
will be returned. This value will be used
as the initial size of the mutable array into which the loading will happen.
Since: 0.5.0
snull :: Load r ix e => Array r ix e -> Bool Source #
O(1) - Check whether a Stream
array is empty or not. It only looks at the exact size
(i.e. slength
), if it is available, otherwise checks if there is at least one element
in a stream.
Related: isEmpty
, isNotEmpty
Examples
>>>
snull sempty
True>>>
snull (empty :: Array D Ix5 Int)
True>>>
snull $ ssingleton "A Vector with a single String element"
False>>>
snull $ sfromList []
True>>>
snull $ sfromList [1 :: Int ..]
False
Similar:
Data.Foldable.
null
- List fusion is also broken with a check for emptiness, unless there are no other consumers of the list.
Data.Vector.Generic.
null
- Same as with
length
, unless it is the only operation applied to the vector it will break fusion and will result in the vector being fully materialized in memory.
Since: 0.5.0
Indexing
(!?) :: (Manifest r ix e, MonadThrow m) => Array r ix e -> ix -> m e infixl 4 Source #
O(1) - Infix version of indexM
.
Exceptions: IndexOutOfBoundsException
Examples
>>>
import Data.Massiv.Array as A
>>>
:set -XTypeApplications
>>>
a <- fromListsM @U @Ix2 @Int Seq [[1,2,3],[4,5,6]]
>>>
a
Array U Seq (Sz (2 :. 3)) [ [ 1, 2, 3 ] , [ 4, 5, 6 ] ]>>>
a !? 0 :. 2
3>>>
a !? 0 :. 3
*** Exception: IndexOutOfBoundsException: (0 :. 3) is not safe for (Sz (2 :. 3))>>>
a !? 0 :. 3 :: Maybe Int
Nothing
Since: 0.1.0
(!) :: Manifest r ix e => Array r ix e -> ix -> e infixl 4 Source #
O(1) - Infix version of index'
.
Examples
>>>
import Data.Massiv.Array as A
>>>
a = computeAs U $ iterateN (Sz (2 :. 3)) succ (0 :: Int)
>>>
a
Array U Seq (Sz (2 :. 3)) [ [ 1, 2, 3 ] , [ 4, 5, 6 ] ]>>>
a ! 0 :. 2
3>>>
a ! 0 :. 3
*** Exception: IndexOutOfBoundsException: (0 :. 3) is not safe for (Sz (2 :. 3))
Since: 0.1.0
index' :: Manifest r ix e => Array r ix e -> ix -> e Source #
O(1) - Lookup an element in the array. This is a partial function and it can throw
IndexOutOfBoundsException
inside pure code. It is safer to use index
instead.
Examples
>>>
import Data.Massiv.Array
>>>
:set -XOverloadedLists
>>>
xs = [0..100] :: Array U Ix1 Int
>>>
index' xs 50
50>>>
index' xs 150
*** Exception: IndexOutOfBoundsException: 150 is not safe for (Sz1 101)
Since: 0.1.0
shead' :: Stream r Ix1 e => Vector r e -> e Source #
O(1) - Get the first element of a Stream
vector. Throws an error on empty.
Related: head'
, headM
, sheadM
, unconsM
.
Examples
>>>
shead' $ sunfoldr (\x -> Just (x, x)) (0 :: Int)
0>>>
x = shead' $ sunfoldr (\_ -> Nothing) (0 :: Int)
>>>
print x
*** Exception: SizeEmptyException: (Sz1 0) corresponds to an empty array
Since: 0.5.0
last' :: Source r Ix1 e => Vector r e -> e Source #
O(1) - Get the last element of a Source
vector. Throws an error on empty.
Examples
>>>
last' (Ix1 10 ... 10000000000000)
10000000000000>>>
last' (fromList Seq [] :: Array P Ix1 Int)
*** Exception: SizeEmptyException: (Sz1 0) corresponds to an empty array
Similar:
Since: 0.5.0
Monadic Indexing
headM :: (Source r Ix1 e, MonadThrow m) => Vector r e -> m e Source #
O(1) - Get the first element of a Source
vector.
Related: head'
, shead'
, sheadM
, unconsM
.
Throws Exceptions: SizeEmptyException
Examples
>>>
headM (Ix1 10 ..: 10000000000000)
10>>>
headM (Ix1 10 ..: 10000000000000) :: Maybe Int
Just 10>>>
headM (empty :: Array D Ix1 Int) :: Maybe Int
Nothing>>>
either show (const "") $ headM (Ix1 10 ..: 10)
"SizeEmptyException: (Sz1 0) corresponds to an empty array"
Similar:
Data.Maybe.
listToMaybe
- It also a safe way to get the head of the list,
except it is restricted to
Maybe
Since: 0.5.0
sheadM :: (Stream r Ix1 e, MonadThrow m) => Vector r e -> m e Source #
O(1) - Get the first element of a Stream
vector.
Related: head'
, shead'
, headM
, unconsM
.
Throws Exceptions: SizeEmptyException
Examples
>>>
maybe 101 id $ sheadM (empty :: Vector D Int)
101>>>
maybe 101 id $ sheadM (singleton 202 :: Vector D Int)
202>>>
sheadM $ sunfoldr (\x -> Just (x, x)) (0 :: Int)
0>>>
x <- sheadM $ sunfoldr (\_ -> Nothing) (0 :: Int)
*** Exception: SizeEmptyException: (Sz1 0) corresponds to an empty array
Since: 0.5.0
lastM :: (Source r Ix1 e, MonadThrow m) => Vector r e -> m e Source #
O(1) - Get the last element of a Source
vector.
Throws Exceptions: SizeEmptyException
Examples
>>>
lastM (Ix1 10 ... 10000000000000)
10000000000000>>>
lastM (Ix1 10 ... 10000000000000) :: Maybe Int
Just 10000000000000>>>
either show (const "") $ lastM (fromList Seq [] :: Array P Ix1 Int)
"SizeEmptyException: (Sz1 0) corresponds to an empty array"
Since: 0.5.0
unconsM :: (MonadThrow m, Source r Ix1 e) => Vector r e -> m (e, Vector D e) Source #
O(1) - Take one element off of the Source
vector from the left side, as well as
the remaining part of the vector in delayed D
representation.
Related: head'
, shead'
, headM
, sheadM
, cons
Throws Exceptions: SizeEmptyException
Examples
>>>
unconsM (fromList Seq [1,2,3] :: Array P Ix1 Int)
(1,Array D Seq (Sz1 2) [ 2, 3 ])
Similar:
Data.List.
uncons
- Same concept, except restricted to
Maybe
instead of the more generalMonadThrow
Since: 0.3.0
unsnocM :: (MonadThrow m, Source r Ix1 e) => Vector r e -> m (Vector D e, e) Source #
O(1) - Take one element off of the vector from the right side, as well as the remaining part of the vector.
Throws Exceptions: SizeEmptyException
Examples
>>>
unsnocM (fromList Seq [1,2,3] :: Array P Ix1 Int)
(Array D Seq (Sz1 2) [ 1, 2 ],3)
Since: 0.3.0
Slicing
slice :: Source r Ix1 e => Ix1 -> Sz1 -> Vector r e -> Vector r e Source #
O(1) - Take a slice of a Source
vector. Never fails, instead adjusts the indices.
Examples
>>>
slice 10 5 (Ix1 0 ... 10000000000000)
Array D Seq (Sz1 5) [ 10, 11, 12, 13, 14 ]>>>
slice (-10) 5 (Ix1 0 ... 10000000000000)
Array D Seq (Sz1 5) [ 0, 1, 2, 3, 4 ]>>>
slice 9999999999998 50 (Ix1 0 ... 10000000000000)
Array D Seq (Sz1 3) [ 9999999999998, 9999999999999, 10000000000000 ]
Since: 0.5.0
slice' :: Source r Ix1 e => Ix1 -> Sz1 -> Vector r e -> Vector r e Source #
O(1) - Take a slice of a Source
vector. Throws an error on incorrect indices.
Examples
>>>
slice' 10 5 (Ix1 0 ... 100)
Array D Seq (Sz1 5) [ 10, 11, 12, 13, 14 ]>>>
slice' (-10) 5 (Ix1 0 ... 100)
Array D *** Exception: SizeSubregionException: (Sz1 101) is to small for -10 (Sz1 5)>>>
slice' 98 50 (Ix1 0 ... 100)
Array D *** Exception: SizeSubregionException: (Sz1 101) is to small for 98 (Sz1 50)>>>
slice' 9999999999998 50 (Ix1 0 ... 10000000000000)
Array D *** Exception: SizeSubregionException: (Sz1 10000000000001) is to small for 9999999999998 (Sz1 50)>>>
slice' 9999999999998 3 (Ix1 0 ... 10000000000000)
Array D Seq (Sz1 3) [ 9999999999998, 9999999999999, 10000000000000 ]
Since: 0.5.0
sliceM :: (Source r Ix1 e, MonadThrow m) => Ix1 -> Sz1 -> Vector r e -> m (Vector r e) Source #
O(1) - Take a slice of a Source
vector. Throws an error on incorrect indices.
Throws Exceptions: SizeSubregionException
Examples
Since: 0.5.0
sslice :: Stream r Ix1 e => Ix1 -> Sz1 -> Vector r e -> Vector DS e Source #
Take a slice of a Stream
vector. Never fails, instead adjusts the indices.
Examples
>>>
sslice 10 5 (Ix1 0 ... 10000000000000)
Array DS Seq (Sz1 5) [ 10, 11, 12, 13, 14 ]>>>
sslice 10 5 (sfromList [0 :: Int .. ])
Array DS Seq (Sz1 5) [ 10, 11, 12, 13, 14 ]>>>
sslice (-10) 5 (Ix1 0 ... 10000000000000)
Array DS Seq (Sz1 5) [ 0, 1, 2, 3, 4 ]
Unlike slice
it has to iterate through each element until the staring index is reached,
therefore something like sslice 9999999999998 50 (Ix1 0 ... 10000000000000)
will not
be feasable.
>>>
import System.Timeout (timeout)
>>>
let smallArr = sslice 9999999999998 50 (Ix1 0 ... 10000000000000)
>>>
timeout 500000 (computeIO smallArr :: IO (Array P Ix1 Int))
Nothing
Since: 0.5.0
sliceAtM :: (Source r Ix1 e, MonadThrow m) => Sz1 -> Vector r e -> m (Vector r e, Vector r e) Source #
Init
init :: Source r Ix1 e => Vector r e -> Vector r e Source #
O(1) - Get a vector without the last element. Never fails.
Examples
>>>
init (0 ..: 10)
Array D Seq (Sz1 9) [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]>>>
init (empty :: Array D Ix1 Int)
Array D Seq (Sz1 0) [ ]
Since: 0.5.0
init' :: Source r Ix1 e => Vector r e -> Vector r e Source #
O(1) - Get a vector without the last element. Throws an error on empty
Examples
>>>
init' (0 ..: 10)
Array D Seq (Sz1 9) [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]>>>
init' (empty :: Array D Ix1 Int)
Array D *** Exception: SizeEmptyException: (Sz1 0) corresponds to an empty array
Since: 0.5.0
initM :: (Source r Ix1 e, MonadThrow m) => Vector r e -> m (Vector r e) Source #
O(1) - Get a vector without the last element. Throws an error on empty
Examples
>>>
initM (0 ..: 10)
Array D Seq (Sz1 9) [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]>>>
maybe 0 sum $ initM (0 ..: 10)
36>>>
maybe 0 sum $ initM (empty :: Array D Ix1 Int)
0
Since: 0.5.0
Tail
tail :: Source r Ix1 e => Vector r e -> Vector r e Source #
O(1) - Get a vector without the first element. Never fails
Examples
>>>
tail (0 ..: 10)
Array D Seq (Sz1 9) [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]>>>
tail (empty :: Array D Ix1 Int)
Array D Seq (Sz1 0) [ ]
Since: 0.5.0
tail' :: Source r Ix1 e => Vector r e -> Vector r e Source #
O(1) - Get a vector without the first element. Throws an error on empty
Examples
λ> tail' (0 ..: 10) Array D Seq (Sz1 9) [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] λ> tail' (empty :: Array D Ix1 Int) Array D *** Exception: SizeEmptyException: (Sz1 0) corresponds to an empty array
Since: 0.5.0
tailM :: (Source r Ix1 e, MonadThrow m) => Vector r e -> m (Vector r e) Source #
O(1) - Get the vector without the first element. Throws an error on empty
Examples
>>>
tailM (0 ..: 10)
Array D Seq (Sz1 9) [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]>>>
maybe 0 sum $ tailM (0 ..: 10)
45>>>
maybe 0 sum $ tailM (empty :: Array D Ix1 Int)
0
Since: 0.5.0
Take
take :: Source r Ix1 e => Sz1 -> Vector r e -> Vector r e Source #
O(1) - Get the vector with the first n
elements. Never fails
Examples
>>>
take 5 (0 ..: 10)
Array D Seq (Sz1 5) [ 0, 1, 2, 3, 4 ]>>>
take (-5) (0 ..: 10)
Array D Seq (Sz1 0) [ ]>>>
take 100 (0 ..: 10)
Array D Seq (Sz1 10) [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]>>>
Since: 0.5.0
take' :: Source r Ix1 e => Sz1 -> Vector r e -> Vector r e Source #
O(1) - Get the vector with the first n
elements. Throws an error size is less
than n
.
Examples
>>>
take' 0 (0 ..: 0)
Array D Seq (Sz1 0) [ ]>>>
take' 5 (0 ..: 10)
Array D Seq (Sz1 5) [ 0, 1, 2, 3, 4 ]>>>
take' 15 (0 ..: 10)
Array D *** Exception: SizeSubregionException: (Sz1 10) is to small for 0 (Sz1 15)
Since: 0.5.0
takeM :: (Source r Ix1 e, MonadThrow m) => Sz1 -> Vector r e -> m (Vector r e) Source #
O(1) - Get the vector with the first n
elements. Throws an error size is less than n
Examples
>>>
takeM 5 (0 ..: 10)
Array D Seq (Sz1 5) [ 0, 1, 2, 3, 4 ]>>>
maybe 0 sum $ takeM 5 (0 ..: 10)
10>>>
maybe (-1) sum $ takeM 15 (0 ..: 10)
-1
Since: 0.5.0
Drop
dropM :: (Source r Ix1 e, MonadThrow m) => Sz1 -> Vector r e -> m (Vector r e) Source #
Examples
Since: 0.5.0
sdrop :: Stream r Ix1 e => Sz1 -> Vector r e -> Vector DS e Source #
Keep all but the first n
elements from the delayed stream vector.
Examples
Since: 0.5.0
Construction
Initialization
empty :: forall r ix e. Construct r ix e => Array r ix e Source #
Create an Array with no elements. By itself it is not particularly useful, but it serves as a nice base for constructing larger arrays.
Examples
>>>
import Data.Massiv.Array as A
>>>
:set -XTypeApplications
>>>
xs = empty @DL @Ix1 @Double
>>>
snoc (cons 4 (cons 5 xs)) 22
Array DL Seq (Sz1 3) [ 4.0, 5.0, 22.0 ]
Since: 0.3.0
Create an Array with a single element.
Examples
>>>
import Data.Massiv.Array as A
>>>
singleton 7 :: Array D Ix4 Double
Array D Seq (Sz (1 :> 1 :> 1 :. 1)) [ [ [ [ 7.0 ] ] ] ]
Instead of specifying type signature we could use TypeApplications
>>>
:set -XTypeApplications
>>>
singleton @U @Ix4 @Double 7
Array U Seq (Sz (1 :> 1 :> 1 :. 1)) [ [ [ [ 7.0 ] ] ] ]
Since: 0.1.0
ssingleton :: e -> Vector DS e Source #
Create a delayed stream vector with a single element
Examples
Since: 0.5.0
cons :: e -> Vector DL e -> Vector DL e Source #
O(1) - Add an element to the vector from the left side
Since: 0.3.0
snoc :: Vector DL e -> e -> Vector DL e Source #
O(1) - Add an element to the vector from the right side
Since: 0.3.0
replicate :: forall ix e. Index ix => Comp -> Sz ix -> e -> Array DL ix e Source #
Replicate the same element
Since: 0.3.0
sreplicate :: Sz1 -> e -> Vector DS e Source #
Replicate the same element n
times
Examples
Since: 0.5.0
generate :: Comp -> Sz1 -> (Ix1 -> e) -> Vector D e Source #
Create a delayed vector of length n
with a function that maps an index to an
element. Same as makeLinearArray
Examples
Since: 0.5.0
sgenerate :: Sz1 -> (Ix1 -> e) -> Vector DS e Source #
Create a delayed stream vector of length n
with a function that maps an index to an
element. Same as makeLinearArray
Examples
Since: 0.5.0
siterate :: (e -> e) -> e -> Vector DS e Source #
Create a delayed stream vector of infinite length by repeatedly applying a function to the initial value.
Examples
>>>
stake 10 $ siterate succ 'a'
Array DS Seq (Sz1 10) [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' ]
Since: 0.5.2
siterateN :: Sz1 -> (e -> e) -> e -> Vector DS e Source #
Create a delayed stream vector of length n
by repeatedly applying a function to the
initial value.
Examples
>>>
siterateN 10 succ 'a'
Array DS Seq (Sz1 10) [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' ]
Since: 0.5.0
Monadic initialization
sreplicateM :: Monad m => Sz1 -> m e -> m (Vector DS e) Source #
Create a vector by using the same monadic action n
times
Examples
Since: 0.5.0
sgenerateM :: Monad m => Sz1 -> (Ix1 -> m e) -> m (Vector DS e) Source #
Create a delayed stream vector of length n
with a monadic action that from an index
generates an element.
Examples
Since: 0.5.0
siterateNM :: Monad m => Sz1 -> (e -> m e) -> e -> m (Vector DS e) Source #
Create a delayed stream vector of length n
by repeatedly apply a monadic action to
the initial value.
Examples
Since: 0.5.0
Unfolding
sunfoldr :: (s -> Maybe (e, s)) -> s -> Vector DS e Source #
Right unfolding function. Useful when it is unknown ahead of time how many elements a vector will have.
Example
>>>
import Data.Massiv.Array as A
>>>
sunfoldr (\i -> if i < 9 then Just (i * i, i + 1) else Nothing) (0 :: Int)
Array DS Seq (Sz1 9) [ 0, 1, 4, 9, 16, 25, 36, 49, 64 ]
Since: 0.5.0
sunfoldrM :: Monad m => (s -> m (Maybe (e, s))) -> s -> m (Vector DS e) Source #
O(n) - Same as unfoldr
, but with monadic generating function.
Examples
>>>
import Control.Monad (when, guard)
>>>
sunfoldrM (\i -> when (i == 0) (Left "Zero denominator") >> Right (guard (i < 5) >> Just (100 `div` i, i + 1))) (-10 :: Int)
Left "Zero denominator">>>
sunfoldrM (\i -> when (i == 0) (Left "Zero denominator") >> Right (guard (i < -5) >> Just (100 `div` i, i + 1))) (-10 :: Int)
Right (Array DS Seq (Sz1 5) [ -10, -12, -13, -15, -17 ] )
Since: 0.5.0
:: Sz1 |
|
-> (s -> Maybe (e, s)) | Unfolding function. Stops when |
-> s | Inititial element. |
-> Vector DS e |
O(n) - Right unfolding function with at most n
number of elements.
Example
>>>
import Data.Massiv.Array as A
>>>
sunfoldrN 9 (\i -> Just (i*i, i + 1)) (0 :: Int)
Array DS Seq (Sz1 9) [ 0, 1, 4, 9, 16, 25, 36, 49, 64 ]
Since: 0.5.0
sunfoldrNM :: Monad m => Sz1 -> (s -> m (Maybe (e, s))) -> s -> m (Vector DS e) Source #
O(n) - Same as unfoldrN
, but with monadic generating function.
Examples
>>>
import Control.Monad (guard)
>>>
sunfoldrNM 6 (\i -> print i >> pure (guard (i < 5) >> Just (i * i, i + 1))) (10 :: Int)
10 Array DS Seq (Sz1 0) [ ]>>>
sunfoldrNM 6 (\i -> print i >> pure (guard (i < 15) >> Just (i * i, i + 1))) (10 :: Int)
10 11 12 13 14 15 Array DS Seq (Sz1 5) [ 100, 121, 144, 169, 196 ]
Since: 0.5.0
sunfoldrExactN :: Sz1 -> (s -> (e, s)) -> s -> Vector DS e Source #
O(n) - Similar to unfoldrN
, except the length of the resulting vector will be exactly n
Examples
>>>
sunfoldrExactN 10 (\i -> (i * i, i + 1)) (10 :: Int)
Array DS Seq (Sz1 10) [ 100, 121, 144, 169, 196, 225, 256, 289, 324, 361 ]
Since: 0.5.0
sunfoldrExactNM :: Monad m => Sz1 -> (s -> m (e, s)) -> s -> m (Vector DS e) Source #
O(n) - Similar to unfoldrNM
, except the length of the resulting vector will be exactly n
Examples
λ> sunfoldrExactNM 11 (i -> pure (100 div
i, i + 1)) (-10 :: Int)
Array DS *** Exception: divide by zero
λ> sunfoldrExactNM 11 (i -> guard (i /= 0) >> Just (100 div
i, i + 1)) (-10 :: Int)
Nothing
λ> sunfoldrExactNM 9 (i -> guard (i /= 0) >> Just (100 div
i, i + 1)) (-10 :: Int)
Just (Array DS Seq (Sz1 9)
[ -10, -12, -13, -15, -17, -20, -25, -34, -50 ]
)
Since: 0.5.0
Enumeration
(...) :: Index ix => ix -> ix -> Array D ix ix infix 4 Source #
Handy synonym for rangeInclusive
Seq
>>>
Ix1 4 ... 10
Array D Seq (Sz1 7) [ 4, 5, 6, 7, 8, 9, 10 ]
Since: 0.3.0
Same as enumFromStepN
with step dx = 1
.
Related: senumFromN
, senumFromStepN
,
enumFromStepN
, rangeSize
, rangeStepSize
, range
Examples
>>>
import Data.Massiv.Array
>>>
enumFromN Seq (5 :: Double) 3
Array D Seq (Sz1 3) [ 5.0, 6.0, 7.0 ]
Similar:
Prelude.
enumFromTo
- Very similar to
[i .. i + n - 1]
, except thatsenumFromN
is faster, but it only works forNum
and not forEnum
elements Data.Vector.Generic.
enumFromN
Since: 0.1.0
O(n) - Enumerate from a starting number x
exactly n
times with a step 1
.
Related: senumFromStepN
, enumFromN
, enumFromStepN
, rangeSize
,
rangeStepSize
, range
, rangeStep
Examples
>>>
senumFromN (10 :: Int) 9
Array DS Seq (Sz1 9) [ 10, 11, 12, 13, 14, 15, 16, 17, 18 ]
Similar:
Prelude.
enumFromTo
- Very similar to
[x .. x + n - 1]
, except thatsenumFromN
is faster and it only works forNum
and not forEnum
elements Data.Vector.Generic.
enumFromN
- Uses exactly the same implementation underneath.
Since: 0.5.0
:: Num e | |
=> Comp | |
-> e |
|
-> e |
|
-> Sz1 |
|
-> Vector D e |
Enumerate from a starting number x
exactly n
times with a custom step value
dx
. Unlike senumFromStepN
, there is no dependency on neigboring
elements therefore enumFromStepN
is parallelizable.
Related: senumFromN
, senumFromStepN
,
enumFromN
, rangeSize
, rangeStepSize
, range
, rangeStepM
Examples
>>>
import Data.Massiv.Array
>>>
enumFromStepN Seq 1 (0.1 :: Double) 5
Array D Seq (Sz1 5) [ 1.0, 1.1, 1.2, 1.3, 1.4 ]>>>
enumFromStepN Seq (-pi :: Float) (pi/4) 9
Array D Seq (Sz1 9) [ -3.1415927, -2.3561945, -1.5707964, -0.78539824, 0.0, 0.78539824, 1.5707963, 2.3561947, 3.1415927 ]
Similar:
Prelude.
enumFrom
- Similar to
take n [x, x + dx ..]
, except thatenumFromStepN
is parallelizable and it only works forNum
and not forEnum
elements. Floating point value will be slightly different as well. Data.Vector.Generic.
enumFromStepN
- Similar in the outcome, but very different in the way it works.
Since: 0.1.0
O(n) - Enumerate from a starting number x
exactly n
times with a custom step value dx
Examples
>>>
senumFromStepN (5 :: Int) 2 10
Array DS Seq (Sz1 10) [ 5, 7, 9, 11, 13, 15, 17, 19, 21, 23 ]
Similar:
Prelude.
enumFrom
- Just like
take n [x, x + dx ..]
, except thatsenumFromN
is faster and it only works forNum
and not forEnum
elements Data.Vector.Generic.
enumFromStepN
- Uses exactly the same implementation underneath.
Since: 0.5.0
Concatenation
sappend :: (Stream r1 Ix1 e, Stream r2 Ix1 e) => Vector r1 e -> Vector r2 e -> Vector DS e Source #
Append two vectors together
Related: appendM
, appendOuterM
,
Examples
λ> sappend (1 ..: 6) (senumFromStepN 6 (-1) 6) Array DS Seq (Sz1 11) [ 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 ]
Similar:
Data.Semigroup.
<>
DS
andDL
arrays have instances forSemigroup
, so they will work in a similar fashion.sappend
differs in that it acceptsStream
arrays with possibly different representations.Data.List.
++
- Same operation, but for lists.
Data.Vector.Generic.
++
- Uses exactly the same implementation
underneath as
sappend
, except that it cannot append two vectors with different memory representations.
Since: 0.5.0
sconcat :: Stream r Ix1 e => [Vector r e] -> Vector DS e Source #
Concat vectors together
Related: concatM
, concatOuterM
,
Examples
>>>
sconcat [2 ... 6, empty, singleton 1, generate Seq 5 id]
Array DS Seq (Sz1 11) [ 2, 3, 4, 5, 6, 1, 0, 1, 2, 3, 4 ]>>>
sconcat [senumFromN 2 5, sempty, ssingleton 1, sgenerate 5 id]
Array DS Seq (Sz1 11) [ 2, 3, 4, 5, 6, 1, 0, 1, 2, 3, 4 ]
Similar:
Data.Monoid.
mconcat
DS
andDL
arrays have instances forMonoid
, so they will work in a similar fashion.sconcat
differs in that it acceptsStream
arrays of other representations.Data.List.
concat
- Same operation, but for lists.
Data.Vector.Generic.
concat
- Uses exactly the same
implementation underneath as
sconcat
.
Since: 0.5.0
smap :: Stream r ix a => (a -> b) -> Array r ix a -> Vector DS b Source #
Map a function over a stream vector
Examples
Since: 0.5.0
simap :: Stream r ix a => (ix -> a -> b) -> Array r ix a -> Vector DS b Source #
Map an index aware function over a stream vector
Examples
Since: 0.5.0
Monadic mapping
straverse :: (Stream r ix a, Applicative f) => (a -> f b) -> Array r ix a -> f (Vector DS b) Source #
Traverse a stream vector with an applicative function.
Examples
Since: 0.5.0
sitraverse :: (Stream r ix a, Applicative f) => (ix -> a -> f b) -> Array r ix a -> f (Vector DS b) Source #
Traverse a stream vector with an index aware applicative function.
Examples
Since: 0.5.0
smapM :: (Stream r ix a, Monad m) => (a -> m b) -> Array r ix a -> m (Vector DS b) Source #
Traverse a stream vector with a monadic function.
Examples
Since: 0.5.0
smapM_ :: (Stream r ix a, Monad m) => (a -> m b) -> Array r ix a -> m () Source #
Traverse a stream vector with a monadic function, while discarding the result
Examples
Since: 0.5.0
simapM :: (Stream r ix a, Monad m) => (ix -> a -> m b) -> Array r ix a -> m (Vector DS b) Source #
Traverse a stream vector with a monadic index aware function.
Corresponds to: mapM (uncurry f) . imap (,) v
Examples
Since: 0.5.0
simapM_ :: (Stream r ix a, Monad m) => (ix -> a -> m b) -> Array r ix a -> m () Source #
Traverse a stream vector with a monadic index aware function, while discarding the result
Examples
Since: 0.5.0
Zipping
szip :: (Stream ra Ix1 a, Stream rb Ix1 b) => Vector ra a -> Vector rb b -> Vector DS (a, b) Source #
Zip two arrays in a row-major order together together into a flat vector. Resulting length of a vector will be the smallest number of elements of the supplied arrays.
Examples
Since: 0.5.0
szip3 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c) => Vector ra a -> Vector rb b -> Vector rc c -> Vector DS (a, b, c) Source #
Since: 0.5.0
szip4 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d) => Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector DS (a, b, c, d) Source #
Since: 0.5.0
szip5 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e) => Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector DS (a, b, c, d, e) Source #
Since: 0.5.0
szip6 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f) => Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> Vector DS (a, b, c, d, e, f) Source #
Since: 0.5.0
szipWith :: (Stream ra Ix1 a, Stream rb Ix1 b) => (a -> b -> c) -> Vector ra a -> Vector rb b -> Vector DS c Source #
Examples
Since: 0.5.0
szipWith3 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c) => (a -> b -> c -> d) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector DS d Source #
Since: 0.5.0
szipWith4 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d) => (a -> b -> c -> d -> e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector DS e Source #
Since: 0.5.0
szipWith5 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e) => (a -> b -> c -> d -> e -> f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector DS f Source #
Since: 0.5.0
szipWith6 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f) => (a -> b -> c -> d -> e -> f -> g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> Vector DS g Source #
Since: 0.5.0
sizipWith :: (Stream ra Ix1 a, Stream rb Ix1 b) => (Ix1 -> a -> b -> c) -> Vector ra a -> Vector rb b -> Vector DS c Source #
Examples
Since: 0.5.0
sizipWith3 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c) => (Ix1 -> a -> b -> c -> d) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector DS d Source #
Since: 0.5.0
sizipWith4 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d) => (Ix1 -> a -> b -> c -> d -> e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector DS e Source #
Since: 0.5.0
sizipWith5 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e) => (Ix1 -> a -> b -> c -> d -> e -> f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector DS f Source #
Since: 0.5.0
sizipWith6 :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f) => (Ix1 -> a -> b -> c -> d -> e -> f -> g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> Vector DS g Source #
Since: 0.5.0
Monadic zipping
szipWithM :: (Stream ra Ix1 a, Stream rb Ix1 b, Monad m) => (a -> b -> m c) -> Vector ra a -> Vector rb b -> m (Vector DS c) Source #
Examples
Since: 0.5.0
szipWith3M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Monad m) => (a -> b -> c -> m d) -> Vector ra a -> Vector rb b -> Vector rc c -> m (Vector DS d) Source #
Since: 0.5.0
szipWith4M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Monad m) => (a -> b -> c -> d -> m e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> m (Vector DS e) Source #
Since: 0.5.0
szipWith5M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Monad m) => (a -> b -> c -> d -> e -> m f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> m (Vector DS f) Source #
Since: 0.5.0
szipWith6M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f, Monad m) => (a -> b -> c -> d -> e -> f -> m g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> m (Vector DS g) Source #
Since: 0.5.0
sizipWithM :: (Stream ra Ix1 a, Stream rb Ix1 b, Monad m) => (Ix1 -> a -> b -> m c) -> Vector ra a -> Vector rb b -> m (Vector DS c) Source #
Examples
Since: 0.5.0
sizipWith3M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Monad m) => (Ix1 -> a -> b -> c -> m d) -> Vector ra a -> Vector rb b -> Vector rc c -> m (Vector DS d) Source #
Since: 0.5.0
sizipWith4M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Monad m) => (Ix1 -> a -> b -> c -> d -> m e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> m (Vector DS e) Source #
Since: 0.5.0
sizipWith5M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Monad m) => (Ix1 -> a -> b -> c -> d -> e -> m f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> m (Vector DS f) Source #
Since: 0.5.0
sizipWith6M :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f, Monad m) => (Ix1 -> a -> b -> c -> d -> e -> f -> m g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> m (Vector DS g) Source #
Examples
Since: 0.5.0
szipWithM_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Monad m) => (a -> b -> m c) -> Vector ra a -> Vector rb b -> m () Source #
Examples
Since: 0.5.0
szipWith3M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Monad m) => (a -> b -> c -> m d) -> Vector ra a -> Vector rb b -> Vector rc c -> m () Source #
Since: 0.5.0
szipWith4M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Monad m) => (a -> b -> c -> d -> m e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> m () Source #
Since: 0.5.0
szipWith5M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Monad m) => (a -> b -> c -> d -> e -> m f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> m () Source #
Since: 0.5.0
szipWith6M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f, Monad m) => (a -> b -> c -> d -> e -> f -> m g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> m () Source #
Since: 0.5.0
sizipWithM_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Monad m) => (Ix1 -> a -> b -> m c) -> Vector ra a -> Vector rb b -> m () Source #
Examples
Since: 0.5.0
sizipWith3M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Monad m) => (Ix1 -> a -> b -> c -> m d) -> Vector ra a -> Vector rb b -> Vector rc c -> m () Source #
Since: 0.5.0
sizipWith4M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Monad m) => (Ix1 -> a -> b -> c -> d -> m e) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> m () Source #
Since: 0.5.0
sizipWith5M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Monad m) => (Ix1 -> a -> b -> c -> d -> e -> m f) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> m () Source #
Since: 0.5.0
sizipWith6M_ :: (Stream ra Ix1 a, Stream rb Ix1 b, Stream rc Ix1 c, Stream rd Ix1 d, Stream re Ix1 e, Stream rf Ix1 f, Monad m) => (Ix1 -> a -> b -> c -> d -> e -> f -> m g) -> Vector ra a -> Vector rb b -> Vector rc c -> Vector rd d -> Vector re e -> Vector rf f -> m () Source #
Since: 0.5.0
Predicates
Filtering
sfilter :: Stream r ix e => (e -> Bool) -> Array r ix e -> Vector DS e Source #
Sequentially filter out elements from the array according to the supplied predicate.
Example
>>>
import Data.Massiv.Array as A
>>>
arr = makeArrayR D Seq (Sz2 3 4) fromIx2
>>>
arr
Array D Seq (Sz (3 :. 4)) [ [ (0,0), (0,1), (0,2), (0,3) ] , [ (1,0), (1,1), (1,2), (1,3) ] , [ (2,0), (2,1), (2,2), (2,3) ] ]>>>
sfilter (even . fst) arr
Array DS Seq (Sz1 8) [ (0,0), (0,1), (0,2), (0,3), (2,0), (2,1), (2,2), (2,3) ]
Since: 0.5.0
sfilterM :: (Stream r ix e, Applicative f) => (e -> f Bool) -> Array r ix e -> f (Vector DS e) Source #
Sequentially filter out elements from the array according to the supplied applicative predicate.
Example
>>>
import Data.Massiv.Array as A
>>>
arr = makeArrayR D Seq (Sz2 3 4) fromIx2
>>>
arr
Array D Seq (Sz (3 :. 4)) [ [ (0,0), (0,1), (0,2), (0,3) ] , [ (1,0), (1,1), (1,2), (1,3) ] , [ (2,0), (2,1), (2,2), (2,3) ] ]>>>
sfilterM (Just . odd . fst) arr
Just (Array DS Seq (Sz1 4) [ (1,0), (1,1), (1,2), (1,3) ] )>>>
sfilterM (\ix@(_, j) -> print ix >> return (even j)) arr
(0,0) (0,1) (0,2) (0,3) (1,0) (1,1) (1,2) (1,3) (2,0) (2,1) (2,2) (2,3) Array DS Seq (Sz1 6) [ (0,0), (0,2), (1,0), (1,2), (2,0), (2,2) ]
Since: 0.5.0
sifilterM :: (Stream r ix a, Applicative f) => (ix -> a -> f Bool) -> Array r ix a -> f (Vector DS a) Source #
Similar to filterM
, but map with an index aware function.
Corresponds to: filterM (uncurry f) . imap (,)
Examples
Since: 0.5.0
smapMaybeM :: (Stream r ix a, Applicative f) => (a -> f (Maybe b)) -> Array r ix a -> f (Vector DS b) Source #
Similar to smapMaybe
, but with the Applicative
function.
Similar to mapMaybe id $ mapM f arr
Examples
Since: 0.5.0
simapMaybeM :: (Stream r ix a, Applicative f) => (ix -> a -> f (Maybe b)) -> Array r ix a -> f (Vector DS b) Source #
Folding
sfoldlM :: (Stream r ix e, Monad m) => (a -> e -> m a) -> a -> Array r ix e -> m a Source #
Examples
Since: 0.5.0
sfoldlM_ :: (Stream r ix e, Monad m) => (a -> e -> m a) -> a -> Array r ix e -> m () Source #
Examples
Since: 0.5.0
sifoldl :: Stream r ix e => (a -> ix -> e -> a) -> a -> Array r ix e -> a Source #
Examples
Since: 0.5.0
sifoldlM :: (Stream r ix e, Monad m) => (a -> ix -> e -> m a) -> a -> Array r ix e -> m a Source #
Examples
Since: 0.5.0
sifoldlM_ :: (Stream r ix e, Monad m) => (a -> ix -> e -> m a) -> a -> Array r ix e -> m () Source #
Examples
Since: 0.5.0
sfoldl1M :: (Stream r ix e, MonadThrow m) => (e -> e -> m e) -> Array r ix e -> m e Source #
Examples
Since: 0.5.0
sfoldl1M_ :: (Stream r ix e, MonadThrow m) => (e -> e -> m e) -> Array r ix e -> m () Source #
Examples
Since: 0.5.0
Specialized folds
smaximumM :: (Ord e, Stream r ix e, MonadThrow m) => Array r ix e -> m e Source #
Examples
Since: 0.5.0
sminimumM :: (Ord e, Stream r ix e, MonadThrow m) => Array r ix e -> m e Source #
Examples
Since: 0.5.0
Conversions
Lists
stoList :: Stream r ix e => Array r ix e -> [e] Source #
Convert an array to a list by the means of a delayed stream vector.
Related: toList
Examples
Since: 0.5.0
Convert a flat list into a vector
Since: 0.1.0
sfromList :: [e] -> Vector DS e Source #
Convert a list to a delayed stream vector
Related: fromList
, fromListN
, sfromListN
Examples
>>>
sfromList ([] :: [Int])
Array DS Seq (Sz1 0) [ ]>>>
sfromList ([1,2,3] :: [Int])
Array DS Seq (Sz1 3) [ 1, 2, 3 ]
Since: 0.5.0
sfromListN :: Sz1 -> [e] -> Vector DS e Source #
Convert a list to a delayed stream vector. Length of the resulting vector will be at
most n
. This version isn't really more efficient then sfromList
, but there is
unsafeFromListN
Related: fromList
, fromListN
, sfromList
Examples
>>>
sfromListN 10 [1 :: Int ..]
Array DS Seq (Sz1 10) [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]>>>
sfromListN 10 [1 :: Int .. 5]
Array DS Seq (Sz1 5) [ 1, 2, 3, 4, 5 ]
Since: 0.5.1
Computation
compute :: forall r ix e r'. (Mutable r ix e, Load r' ix e) => Array r' ix e -> Array r ix e Source #
computeS :: forall r ix e r'. (Mutable r ix e, Load r' ix e) => Array r' ix e -> Array r ix e Source #
Compute array sequentially disregarding predefined computation strategy. Very much
the same as computePrimM
, but executed in ST
, thus pure.
Since: 0.1.0
computeIO :: forall r ix e r' m. (Mutable r ix e, Load r' ix e, MonadIO m) => Array r' ix e -> m (Array r ix e) Source #
computePrimM :: forall r ix e r' m. (Mutable r ix e, Load r' ix e, PrimMonad m) => Array r' ix e -> m (Array r ix e) Source #
Compute an array in PrimMonad
sequentially disregarding predefined computation
strategy.
Since: 0.4.5
computeAs :: (Mutable r ix e, Load r' ix e) => r -> Array r' ix e -> Array r ix e Source #
Just as compute
, but let's you supply resulting representation type as an argument.
Examples
>>>
import Data.Massiv.Array
>>>
computeAs P $ range Seq (Ix1 0) 10
Array P Seq (Sz1 10) [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
computeProxy :: (Mutable r ix e, Load r' ix e) => proxy r -> Array r' ix e -> Array r ix e Source #
Same as compute
and computeAs
, but let's you supply resulting representation type as a proxy
argument.
Examples
Useful only really for cases when representation constructor or TypeApplications
extension
aren't desireable for some reason:
>>>
import Data.Proxy
>>>
import Data.Massiv.Array
>>>
computeProxy (Proxy :: Proxy P) $ (^ (2 :: Int)) <$> range Seq (Ix1 0) 10
Array P Seq (Sz1 10) [ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 ]
Since: 0.1.1
computeSource :: forall r ix e r'. (Mutable r ix e, Source r' ix e) => Array r' ix e -> Array r ix e Source #
computeWithStride :: forall r ix e r'. (Mutable r ix e, StrideLoad r' ix e) => Stride ix -> Array r' ix e -> Array r ix e Source #
computeWithStrideAs :: (Mutable r ix e, StrideLoad r' ix e) => r -> Stride ix -> Array r' ix e -> Array r ix e Source #
Same as computeWithStride
, but with ability to specify resulting array representation.
Since: 0.3.0
clone :: Mutable r ix e => Array r ix e -> Array r ix e Source #
O(n) - Make an exact immutable copy of an Array.
Since: 0.1.0
convert :: forall r ix e r'. (Mutable r ix e, Load r' ix e) => Array r' ix e -> Array r ix e Source #
O(n) - conversion between array types. A full copy will occur, unless when the source and result arrays are of the same representation, in which case it is an O(1) operation.
Since: 0.1.0
convertAs :: (Mutable r ix e, Load r' ix e) => r -> Array r' ix e -> Array r ix e Source #
Same as convert
, but let's you supply resulting representation type as an argument.
Since: 0.1.0
Deprecated
filterM :: (Stream r ix e, Applicative f) => (e -> f Bool) -> Array r ix e -> f (Vector DS e) Source #
ifilterM :: (Source r ix a, Applicative f) => (ix -> a -> f Bool) -> Array r ix a -> f (Array DS Ix1 a) Source #
mapMaybeM :: (Stream r ix a, Applicative f) => (a -> f (Maybe b)) -> Array r ix a -> f (Vector DS b) Source #
imapMaybeM :: (Source r ix a, Applicative f) => (ix -> a -> f (Maybe b)) -> Array r ix a -> f (Array DS Ix1 b) Source #
traverseS :: (Stream r ix a, Applicative f) => (a -> f b) -> Array r ix a -> f (Vector DS b) Source #
Re-exports
module Data.Massiv.Core
module Data.Massiv.Array.Delayed
module Data.Massiv.Array.Manifest
module Data.Massiv.Array.Mutable