Copyright | (c) Christopher Chalmers |
---|---|
License | BSD3 |
Maintainer | Christopher Chalmers |
Stability | provisional |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Base module for multidimensional arrays. This module exports the
constructors for the Array
data type.
Also, to prevent this module becomming too large, only the data types and the functions nessesary for the instances are defined here. All other functions are defined in Data.Dense.Generic.
Synopsis
- data Array v f a = Array !(Layout f) !(v a)
- type Boxed v = v ~ Vector
- vector :: (Vector v a, Vector w b) => IndexedLens (Layout f) (Array v f a) (Array w f b) (v a) (w b)
- values :: (Shape f, Vector v a, Vector w b) => IndexedTraversal (f Int) (Array v f a) (Array w f b) a b
- unsafeThaw :: (PrimMonad m, Vector v a) => Array v f a -> m (MArray (Mutable v) f (PrimState m) a)
- unsafeFreeze :: (PrimMonad m, Vector v a) => MArray (Mutable v) f (PrimState m) a -> m (Array v f a)
- data Delayed f a = Delayed !(Layout f) (f Int -> a)
- delay :: (Vector v a, Shape f) => Array v f a -> Delayed f a
- manifest :: (Vector v a, Shape f) => Delayed f a -> Array v f a
- genDelayed :: Layout f -> (f Int -> a) -> Delayed f a
- indexDelayed :: Shape f => Delayed f a -> f Int -> a
- data Focused f a = Focused !(f Int) !(Delayed f a)
Array types
An Array
is a vector with a shape.
Instances
Shape f => HasLayout f (Array v f a) Source # | The |
(Boxed v, Shape f) => FunctorWithIndex (f Int) (Array v f) Source # | |
(Boxed v, Shape f) => FoldableWithIndex (f Int) (Array v f) Source # | |
Defined in Data.Dense.Base ifoldMap :: Monoid m => (f Int -> a -> m) -> Array v f a -> m # ifolded :: IndexedFold (f Int) (Array v f a) a # ifoldr :: (f Int -> a -> b -> b) -> b -> Array v f a -> b # ifoldl :: (f Int -> b -> a -> b) -> b -> Array v f a -> b # ifoldr' :: (f Int -> a -> b -> b) -> b -> Array v f a -> b # ifoldl' :: (f Int -> b -> a -> b) -> b -> Array v f a -> b # | |
(Boxed v, Shape f) => TraversableWithIndex (f Int) (Array v f) Source # | |
Defined in Data.Dense.Base itraverse :: Applicative f0 => (f Int -> a -> f0 b) -> Array v f a -> f0 (Array v f b) # itraversed :: IndexedTraversal (f Int) (Array v f a) (Array v f b) a b # | |
Boxed v => Functor (Array v f) Source # | |
Boxed v => Foldable (Array v f) Source # | |
Defined in Data.Dense.Base fold :: Monoid m => Array v f m -> m # foldMap :: Monoid m => (a -> m) -> Array v f a -> m # foldMap' :: Monoid m => (a -> m) -> Array v f a -> m # foldr :: (a -> b -> b) -> b -> Array v f a -> b # foldr' :: (a -> b -> b) -> b -> Array v f a -> b # foldl :: (b -> a -> b) -> b -> Array v f a -> b # foldl' :: (b -> a -> b) -> b -> Array v f a -> b # foldr1 :: (a -> a -> a) -> Array v f a -> a # foldl1 :: (a -> a -> a) -> Array v f a -> a # toList :: Array v f a -> [a] # length :: Array v f a -> Int # elem :: Eq a => a -> Array v f a -> Bool # maximum :: Ord a => Array v f a -> a # minimum :: Ord a => Array v f a -> a # | |
Boxed v => Traversable (Array v f) Source # | |
(Boxed v, Eq1 f) => Eq1 (Array v f) Source # | |
(Boxed v, Read1 f) => Read1 (Array v f) Source # | |
Defined in Data.Dense.Base | |
(Boxed v, Shape f, Serial1 f) => Serial1 (Array v f) Source # | |
Defined in Data.Dense.Base serializeWith :: MonadPut m => (a -> m ()) -> Array v f a -> m () # deserializeWith :: MonadGet m => m a -> m (Array v f a) # | |
(Vector v a, f ~ V1) => Vector (Array v f) a Source # | 1D Arrays can be used as a generic |
Defined in Data.Dense.Base basicUnsafeFreeze :: PrimMonad m => Mutable (Array v f) (PrimState m) a -> m (Array v f a) # basicUnsafeThaw :: PrimMonad m => Array v f a -> m (Mutable (Array v f) (PrimState m) a) # basicLength :: Array v f a -> Int # basicUnsafeSlice :: Int -> Int -> Array v f a -> Array v f a # basicUnsafeIndexM :: Monad m => Array v f a -> Int -> m a # basicUnsafeCopy :: PrimMonad m => Mutable (Array v f) (PrimState m) a -> Array v f a -> m () # | |
(Vector v a, Eq1 f, Eq a) => Eq (Array v f a) Source # | |
(Typeable f, Typeable v, Typeable a, Data (f Int), Data (v a)) => Data (Array v f a) Source # | |
Defined in Data.Dense.Base gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Array v f a -> c (Array v f a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Array v f a) # toConstr :: Array v f a -> Constr # dataTypeOf :: Array v f a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Array v f a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Array v f a)) # gmapT :: (forall b. Data b => b -> b) -> Array v f a -> Array v f a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Array v f a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Array v f a -> r # gmapQ :: (forall d. Data d => d -> u) -> Array v f a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Array v f a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Array v f a -> m (Array v f a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Array v f a -> m (Array v f a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Array v f a -> m (Array v f a) # | |
(Vector v a, Read1 f, Read a) => Read (Array v f a) Source # | |
(Vector v a, Show1 f, Show a) => Show (Array v f a) Source # | |
(Vector v a, Shape f, Binary (f Int), Binary a) => Binary (Array v f a) Source # | |
(Vector v a, Shape f, Serial1 f, Serial a) => Serial (Array v f a) Source # | |
Defined in Data.Dense.Base | |
(Vector v a, Shape f, Serialize (f Int), Serialize a) => Serialize (Array v f a) Source # | |
(NFData (f Int), NFData (v a)) => NFData (Array v f a) Source # | |
Defined in Data.Dense.Base | |
(Vector v a, Foldable f, Hashable a) => Hashable (Array v f a) Source # | |
Defined in Data.Dense.Base | |
(Shape f, Vector v a) => Ixed (Array v f a) Source # | |
Defined in Data.Dense.Base | |
(Shape f, Vector v a) => AsEmpty (Array v f a) Source # | |
Defined in Data.Dense.Base | |
(Vector v a, Vector v b) => Each (Array v f a) (Array v f b) a b Source # | |
type Mutable (Array v f) Source # | |
Defined in Data.Dense.Base | |
type Index (Array v f a) Source # | |
Defined in Data.Dense.Base | |
type IxValue (Array v f a) Source # | |
Defined in Data.Dense.Base |
Lenses
vector :: (Vector v a, Vector w b) => IndexedLens (Layout f) (Array v f a) (Array w f b) (v a) (w b) Source #
values :: (Shape f, Vector v a, Vector w b) => IndexedTraversal (f Int) (Array v f a) (Array w f b) a b Source #
Indexed traversal over the elements of an array. The index is the current position in the array.
Conversion to/from mutable arrays
unsafeThaw :: (PrimMonad m, Vector v a) => Array v f a -> m (MArray (Mutable v) f (PrimState m) a) Source #
O(1) Unsafely convert an immutable array to a mutable one without copying. The immutable array may not be used after this operation.
unsafeFreeze :: (PrimMonad m, Vector v a) => MArray (Mutable v) f (PrimState m) a -> m (Array v f a) Source #
O(1) Unsafe convert a mutable array to an immutable one without copying. The mutable array may not be used after this operation.
Delayed
A delayed representation of an array. This useful for mapping over an array in parallel.
Instances
Shape f => HasLayout f (Delayed f a) Source # | The |
Functor (Delayed f) Source # | |
Shape f => Foldable (Delayed f) Source # |
|
Defined in Data.Dense.Base fold :: Monoid m => Delayed f m -> m # foldMap :: Monoid m => (a -> m) -> Delayed f a -> m # foldMap' :: Monoid m => (a -> m) -> Delayed f a -> m # foldr :: (a -> b -> b) -> b -> Delayed f a -> b # foldr' :: (a -> b -> b) -> b -> Delayed f a -> b # foldl :: (b -> a -> b) -> b -> Delayed f a -> b # foldl' :: (b -> a -> b) -> b -> Delayed f a -> b # foldr1 :: (a -> a -> a) -> Delayed f a -> a # foldl1 :: (a -> a -> a) -> Delayed f a -> a # toList :: Delayed f a -> [a] # length :: Delayed f a -> Int # elem :: Eq a => a -> Delayed f a -> Bool # maximum :: Ord a => Delayed f a -> a # minimum :: Ord a => Delayed f a -> a # | |
Shape f => Traversable (Delayed f) Source # | |
Shape f => Apply (Delayed f) Source # | |
Shape f => Metric (Delayed f) Source # | |
Defined in Data.Dense.Base | |
Shape f => Additive (Delayed f) Source # | |
Defined in Data.Dense.Base zero :: Num a => Delayed f a # (^+^) :: Num a => Delayed f a -> Delayed f a -> Delayed f a # (^-^) :: Num a => Delayed f a -> Delayed f a -> Delayed f a # lerp :: Num a => a -> Delayed f a -> Delayed f a -> Delayed f a # liftU2 :: (a -> a -> a) -> Delayed f a -> Delayed f a -> Delayed f a # liftI2 :: (a -> b -> c) -> Delayed f a -> Delayed f b -> Delayed f c # | |
FunctorWithIndex (f Int) (Delayed f) Source # | |
Shape f => FoldableWithIndex (f Int) (Delayed f) Source # |
|
Defined in Data.Dense.Base ifoldMap :: Monoid m => (f Int -> a -> m) -> Delayed f a -> m # ifolded :: IndexedFold (f Int) (Delayed f a) a # ifoldr :: (f Int -> a -> b -> b) -> b -> Delayed f a -> b # ifoldl :: (f Int -> b -> a -> b) -> b -> Delayed f a -> b # ifoldr' :: (f Int -> a -> b -> b) -> b -> Delayed f a -> b # ifoldl' :: (f Int -> b -> a -> b) -> b -> Delayed f a -> b # | |
Shape f => TraversableWithIndex (f Int) (Delayed f) Source # | |
Defined in Data.Dense.Base itraverse :: Applicative f0 => (f Int -> a -> f0 b) -> Delayed f a -> f0 (Delayed f b) # itraversed :: IndexedTraversal (f Int) (Delayed f a) (Delayed f b) a b # | |
(Shape f, Show1 f, Show a) => Show (Delayed f a) Source # | |
Shape f => Ixed (Delayed f a) Source # | |
Defined in Data.Dense.Base | |
Shape f => AsEmpty (Delayed f a) Source # | |
Defined in Data.Dense.Base | |
Shape f => Each (Delayed f a) (Delayed f b) a b Source # | |
type Index (Delayed f a) Source # | |
Defined in Data.Dense.Base | |
type IxValue (Delayed f a) Source # | |
Defined in Data.Dense.Base |
delay :: (Vector v a, Shape f) => Array v f a -> Delayed f a Source #
Turn a material array into a delayed one with the same shape.
manifest :: (Vector v a, Shape f) => Delayed f a -> Array v f a Source #
Parallel manifestation of a delayed array into a material one.
indexDelayed :: Shape f => Delayed f a -> f Int -> a Source #
Index a delayed array, returning a IndexOutOfBounds
exception if
the index is out of range.
Focused
A delayed representation of an array with a focus on a single
element. This element is the target of extract
.
Instances
Shape f => HasLayout f (Focused f a) Source # | The |
Functor (Focused f) Source # | |
Shape f => Foldable (Focused f) Source # | |
Defined in Data.Dense.Base fold :: Monoid m => Focused f m -> m # foldMap :: Monoid m => (a -> m) -> Focused f a -> m # foldMap' :: Monoid m => (a -> m) -> Focused f a -> m # foldr :: (a -> b -> b) -> b -> Focused f a -> b # foldr' :: (a -> b -> b) -> b -> Focused f a -> b # foldl :: (b -> a -> b) -> b -> Focused f a -> b # foldl' :: (b -> a -> b) -> b -> Focused f a -> b # foldr1 :: (a -> a -> a) -> Focused f a -> a # foldl1 :: (a -> a -> a) -> Focused f a -> a # toList :: Focused f a -> [a] # length :: Focused f a -> Int # elem :: Eq a => a -> Focused f a -> Bool # maximum :: Ord a => Focused f a -> a # minimum :: Ord a => Focused f a -> a # | |
Shape f => Traversable (Focused f) Source # | |
Shape f => Comonad (Focused f) Source # | |
Shape f => Extend (Focused f) Source # | |
Shape f => ComonadStore (f Int) (Focused f) Source # | |
Defined in Data.Dense.Base | |
Shape f => FunctorWithIndex (f Int) (Focused f) Source # | Index relative to focus. |
Shape f => FoldableWithIndex (f Int) (Focused f) Source # | Index relative to focus. |
Defined in Data.Dense.Base ifoldMap :: Monoid m => (f Int -> a -> m) -> Focused f a -> m # ifolded :: IndexedFold (f Int) (Focused f a) a # ifoldr :: (f Int -> a -> b -> b) -> b -> Focused f a -> b # ifoldl :: (f Int -> b -> a -> b) -> b -> Focused f a -> b # ifoldr' :: (f Int -> a -> b -> b) -> b -> Focused f a -> b # ifoldl' :: (f Int -> b -> a -> b) -> b -> Focused f a -> b # | |
Shape f => TraversableWithIndex (f Int) (Focused f) Source # | Index relative to focus. |
Defined in Data.Dense.Base itraverse :: Applicative f0 => (f Int -> a -> f0 b) -> Focused f a -> f0 (Focused f b) # itraversed :: IndexedTraversal (f Int) (Focused f a) (Focused f b) a b # | |
(Shape f, Show1 f, Show a) => Show (Focused f a) Source # | |
Shape f => Ixed (Focused f a) Source # | Index relative to focus. |
Defined in Data.Dense.Base | |
type Index (Focused f a) Source # | |
Defined in Data.Dense.Base | |
type IxValue (Focused f a) Source # | |
Defined in Data.Dense.Base |