dense-0.1.0.1: Mutable and immutable dense multidimensional arrays
Copyright(c) Christopher Chalmers
LicenseBSD3
MaintainerChristopher Chalmers
Stabilityprovisional
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Dense.Unboxed

Description

Unboxed multidimensional arrays.

Synopsis

UArray types

type UArray = Array Vector Source #

Unboxed array.

class (Vector Vector a, MVector MVector a) => Unbox a #

Instances

Instances details
Unbox Bool 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Char 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Double 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Float 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Int 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Int8 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Int16 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Int32 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Int64 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Word 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Word8 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Word16 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Word32 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Word64 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox () 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox All 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox Any 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Complex a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Min a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Max a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (First a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Last a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (WrappedMonoid a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Identity a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Dual a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Sum a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Product a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Down a) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Plucker a) 
Instance details

Defined in Linear.Plucker

Unbox a => Unbox (Quaternion a) 
Instance details

Defined in Linear.Quaternion

Unbox (V0 a) 
Instance details

Defined in Linear.V0

Unbox a => Unbox (V4 a) 
Instance details

Defined in Linear.V4

Unbox a => Unbox (V3 a) 
Instance details

Defined in Linear.V3

Unbox a => Unbox (V2 a) 
Instance details

Defined in Linear.V2

Unbox a => Unbox (V1 a) 
Instance details

Defined in Linear.V1

(Unbox a, Unbox b) => Unbox (a, b) 
Instance details

Defined in Data.Vector.Unboxed.Base

(Unbox a, Unbox b) => Unbox (Arg a b) 
Instance details

Defined in Data.Vector.Unboxed.Base

(Unbox a, Unbox b, Unbox c) => Unbox (a, b, c) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox a => Unbox (Const a b) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox (f a) => Unbox (Alt f a) 
Instance details

Defined in Data.Vector.Unboxed.Base

(Dim n, Unbox a) => Unbox (V n a) 
Instance details

Defined in Linear.V

(Unbox a, Unbox b, Unbox c, Unbox d) => Unbox (a, b, c, d) 
Instance details

Defined in Data.Vector.Unboxed.Base

(Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Unbox (a, b, c, d, e) 
Instance details

Defined in Data.Vector.Unboxed.Base

Unbox (f (g a)) => Unbox (Compose f g a) 
Instance details

Defined in Data.Vector.Unboxed.Base

(Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Unbox (a, b, c, d, e, f) 
Instance details

Defined in Data.Vector.Unboxed.Base

class (Eq1 f, Additive f, Traversable f) => Shape f Source #

Class for types that can be converted to and from linear indexes.

Instances

Instances details
Shape V0 Source # 
Instance details

Defined in Data.Dense.Index

Shape V4 Source # 
Instance details

Defined in Data.Dense.Index

Shape V3 Source # 
Instance details

Defined in Data.Dense.Index

Shape V2 Source # 
Instance details

Defined in Data.Dense.Index

Shape V1 Source # 
Instance details

Defined in Data.Dense.Index

Layout of an array

class Shape f => HasLayout f a | a -> f where Source #

Class of things that have a Layout. This means we can use the same functions for the various different arrays in the library.

Minimal complete definition

Nothing

Methods

layout :: Lens' a (Layout f) Source #

Lens onto the Layout of something.

default layout :: a ~ f Int => (Layout f -> g (Layout f)) -> a -> g a Source #

Instances

Instances details
i ~ Int => HasLayout V0 (V0 i) Source # 
Instance details

Defined in Data.Dense.Index

Methods

layout :: Lens' (V0 i) (Layout V0) Source #

i ~ Int => HasLayout V4 (V4 i) Source # 
Instance details

Defined in Data.Dense.Index

Methods

layout :: Lens' (V4 i) (Layout V4) Source #

i ~ Int => HasLayout V3 (V3 i) Source # 
Instance details

Defined in Data.Dense.Index

Methods

layout :: Lens' (V3 i) (Layout V3) Source #

i ~ Int => HasLayout V2 (V2 i) Source # 
Instance details

Defined in Data.Dense.Index

Methods

layout :: Lens' (V2 i) (Layout V2) Source #

i ~ Int => HasLayout V1 (V1 i) Source # 
Instance details

Defined in Data.Dense.Index

Methods

layout :: Lens' (V1 i) (Layout V1) Source #

Shape f => HasLayout f (Focused f a) Source #

The size of the layout must remain the same or an error is thrown.

Instance details

Defined in Data.Dense.Base

Methods

layout :: Lens' (Focused f a) (Layout f) Source #

Shape f => HasLayout f (Delayed f a) Source #

The size of the layout must remain the same or an error is thrown.

Instance details

Defined in Data.Dense.Base

Methods

layout :: Lens' (Delayed f a) (Layout f) Source #

Shape f => HasLayout f (Array v f a) Source #

The size of the layout must remain the same or an error is thrown.

Instance details

Defined in Data.Dense.Base

Methods

layout :: Lens' (Array v f a) (Layout f) Source #

Shape f => HasLayout f (MArray v f s a) Source # 
Instance details

Defined in Data.Dense.Mutable

Methods

layout :: Lens' (MArray v f s a) (Layout f) Source #

type Layout f = f Int Source #

A Layout is the full size of an array. This alias is used to help distinguish between the layout of an array and an index (usually just l Int) in a type signature.

Extracting size

extent :: HasLayout f a => a -> f Int Source #

Get the extent of an array.

extent :: Array v f a    -> f Int
extent :: MArray v f s a -> f Int
extent :: Delayed f a    -> f Int
extent :: Focused f a    -> f Int

size :: HasLayout f a => a -> Int Source #

Get the total number of elements in an array.

size :: Array v f a    -> Int
size :: MArray v f s a -> Int
size :: Delayed f a    -> Int
size :: Focused f a    -> Int

Folds over indexes

indexes :: HasLayout f a => IndexedFold Int a (f Int) Source #

Indexed fold for all the indexes in the layout.

indexesFrom :: HasLayout f a => f Int -> IndexedFold Int a (f Int) Source #

Indexed fold starting starting from some point, where the index is the linear index for the original layout.

indexesBetween :: HasLayout f a => f Int -> f Int -> IndexedFold Int a (f Int) Source #

Indexed fold between the two indexes where the index is the linear index for the original layout.

Underlying vector

vector :: (Unbox a, Unbox b) => IndexedLens (Layout f) (UArray f a) (UArray f b) (Vector a) (Vector b) Source #

Indexed lens over the underlying vector of an array. The index is the extent of the array. You must _not_ change the length of the vector, otherwise an error will be thrown (even for V1 layouts, use flat for V1).

Traversals

values :: (Shape f, Unbox a, Unbox b) => IndexedTraversal (f Int) (UArray f a) (UArray f b) a b Source #

Same as values but restrictive in the vector type.

values' :: (Shape f, Unbox a, Unbox b) => IndexedTraversal (f Int) (UArray f a) (UArray f b) a b Source #

Same as values but restrictive in the vector type.

valuesBetween :: (Shape f, Unbox a) => f Int -> f Int -> IndexedTraversal' (f Int) (UArray f a) a Source #

Same as values but restrictive in the vector type.

Construction

Flat arrays

flat :: Unbox b => Iso (UArray V1 a) (UArray V1 b) (Vector a) (Vector b) Source #

1D arrays are just vectors. You are free to change the length of the vector when going over this Iso (unlike linear).

Note that V1 arrays are an instance of Vector so you can use any of the functions in Generic on them without needing to convert.

fromList :: Unbox a => [a] -> UArray V1 a Source #

Contruct a flat array from a list. (This is just fromList from Generic.)

From lists

fromListInto :: (Shape f, Unbox a) => Layout f -> [a] -> Maybe (UArray f a) Source #

O(n) Convert the first n elements of a list to an UArrayith the given shape. Returns Nothing if there are not enough elements in the list.

fromListInto_ :: (Shape f, Unbox a) => Layout f -> [a] -> UArray f a Source #

O(n) Convert the first n elements of a list to an UArrayith the given shape. Throw an error if the list is not long enough.

From vectors

fromVectorInto :: (Shape f, Unbox a) => Layout f -> Vector a -> Maybe (UArray f a) Source #

Create an array from a vector and a layout. Return Nothing if the vector is not the right shape.

fromVectorInto_ :: (Shape f, Unbox a) => Layout f -> Vector a -> UArray f a Source #

Create an array from a vector and a layout. Throws an error if the vector is not the right shape.

Initialisation

replicate :: (Shape f, Unbox a) => f Int -> a -> UArray f a Source #

O(n) UArray of the given shape with the same value in each position.

generate :: (Shape f, Unbox a) => Layout f -> (f Int -> a) -> UArray f a Source #

O(n) Construct an array of the given shape by applying the function to each index.

linearGenerate :: (Shape f, Unbox a) => Layout f -> (Int -> a) -> UArray f a Source #

O(n) Construct an array of the given shape by applying the function to each index.

Monadic initialisation

create :: Unbox a => (forall s. ST s (UMArray f s a)) -> UArray f a Source #

Execute the monadic action and freeze the resulting array.

replicateM :: (Monad m, Shape f, Unbox a) => Layout f -> m a -> m (UArray f a) Source #

O(n) Construct an array of the given shape by filling each position with the monadic value.

generateM :: (Monad m, Shape f, Unbox a) => Layout f -> (f Int -> m a) -> m (UArray f a) Source #

O(n) Construct an array of the given shape by applying the monadic function to each index.

linearGenerateM :: (Monad m, Shape f, Unbox a) => Layout f -> (Int -> m a) -> m (UArray f a) Source #

O(n) Construct an array of the given shape by applying the monadic function to each index.

Functions on arrays

Empty arrays

empty :: (Unbox a, Additive f) => UArray f a Source #

The empty UArray with a zero shape.

null :: Foldable f => UArray f a -> Bool Source #

Test is if the array is empty.

Indexing

(!) :: (Shape f, Unbox a) => UArray f a -> f Int -> a Source #

Index an element of an array. Throws IndexOutOfBounds if the index is out of bounds.

(!?) :: (Shape f, Unbox a) => UArray f a -> f Int -> Maybe a Source #

Safe index of an element.

unsafeIndex :: (Shape f, Unbox a) => UArray f a -> f Int -> a Source #

Index an element of an array without bounds checking.

linearIndex :: Unbox a => UArray f a -> Int -> a Source #

Index an element of an array while ignoring its shape.

unsafeLinearIndex :: Unbox a => UArray f a -> Int -> a Source #

Index an element of an array while ignoring its shape, without bounds checking.

Monadic indexing

indexM :: (Shape f, Unbox a, Monad m) => UArray f a -> f Int -> m a Source #

O(1) Indexing in a monad.

The monad allows operations to be strict in the vector when necessary. Suppose vector copying is implemented like this:

copy mv v = ... write mv i (v ! i) ...

For lazy vectors, v ! i would not be evaluated which means that mv would unnecessarily retain a reference to v in each element written.

With indexM, copying can be implemented like this instead:

copy mv v = ... do
  x <- indexM v i
  write mv i x

Here, no references to v are retained because indexing (but not the elements) is evaluated eagerly.

Throws an error if the index is out of range.

unsafeIndexM :: (Shape f, Unbox a, Monad m) => UArray f a -> f Int -> m a Source #

O(1) Indexing in a monad without bounds checks. See indexM for an explanation of why this is useful.

linearIndexM :: (Shape f, Unbox a, Monad m) => UArray f a -> Int -> m a Source #

O(1) Indexing in a monad. Throws an error if the index is out of range.

unsafeLinearIndexM :: (Unbox a, Monad m) => UArray f a -> Int -> m a Source #

O(1) Indexing in a monad without bounds checks. See indexM for an explanation of why this is useful.

Modifying arrays

Bulk updates

(//) :: (Unbox a, Shape f) => UArray f a -> [(f Int, a)] -> UArray f a Source #

For each pair (i,a) from the list, replace the array element at position i by a.

Accumulations

accum Source #

Arguments

:: (Shape f, Unbox a) 
=> (a -> b -> a)

accumulating function f

-> UArray f a

initial array

-> [(f Int, b)]

list of index/value pairs (of length n)

-> UArray f a 

O(m+n) For each pair (i,b) from the list, replace the array element a at position i by f a b.

Mapping

map :: (Unbox a, Unbox b) => (a -> b) -> UArray f a -> UArray f b Source #

O(n) Map a function over an array

imap :: (Shape f, Unbox a, Unbox b) => (f Int -> a -> b) -> UArray f a -> UArray f b Source #

O(n) Apply a function to every element of a vector and its index

Zipping

Tuples

zip :: (Shape f, Unbox a, Unbox b) => UArray f a -> UArray f b -> UArray f (a, b) Source #

Zip two arrays element wise. If the array's don't have the same shape, the new array with be the intersection of the two shapes.

zip3 :: (Shape f, Unbox a, Unbox b, Unbox c) => UArray f a -> UArray f b -> UArray f c -> UArray f (a, b, c) Source #

Zip three arrays element wise. If the array's don't have the same shape, the new array with be the intersection of the two shapes.

Zip with function

zipWith :: (Shape f, Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> UArray f a -> UArray f b -> UArray f c Source #

Zip two arrays using the given function. If the array's don't have the same shape, the new array with be the intersection of the two shapes.

zipWith3 :: (Shape f, Unbox a, Unbox b, Unbox c, Unbox d) => (a -> b -> c -> d) -> UArray f a -> UArray f b -> UArray f c -> UArray f d Source #

Zip three arrays using the given function. If the array's don't have the same shape, the new array with be the intersection of the two shapes.

izipWith :: (Shape f, Unbox a, Unbox b, Unbox c) => (f Int -> a -> b -> c) -> UArray f a -> UArray f b -> UArray f c Source #

Zip two arrays using the given function with access to the index. If the array's don't have the same shape, the new array with be the intersection of the two shapes.

izipWith3 :: (Shape f, Unbox a, Unbox b, Unbox c, Unbox d) => (f Int -> a -> b -> c -> d) -> UArray f a -> UArray f b -> UArray f c -> UArray f d Source #

Zip two arrays using the given function with access to the index. If the array's don't have the same shape, the new array with be the intersection of the two shapes.

Slices

Matrix

ixRow :: Unbox a => Int -> IndexedTraversal' Int (UArray V2 a) (Vector a) Source #

Affine traversal over a single row in a matrix.

>>> traverseOf_ rows print $ m & ixRow 1 . each +~ 2
[1,2,3]
[6,7,8]

The row vector should remain the same size to satisfy traversal laws but give reasonable behaviour if the size differs:

>>> traverseOf_ rows print $ m & ixRow 1 .~ V.fromList [0,1]
[1,2,3]
[0,1,6]
>>> traverseOf_ rows print $ m & ixRow 1 .~ V.fromList [0..100]
[1,2,3]
[0,1,2]

rows :: (Unbox a, Unbox b) => IndexedTraversal Int (UArray V2 a) (UArray V2 b) (Vector a) (Vector b) Source #

Indexed traversal over the rows of a matrix. Each row is an efficient slice of the original vector.

>>> traverseOf_ rows print m
[1,2,3]
[4,5,6]

ixColumn :: Unbox a => Int -> IndexedTraversal' Int (UArray V2 a) (Vector a) Source #

Affine traversal over a single column in a matrix.

>>> traverseOf_ rows print $ m & ixColumn 2 . each *~ 10
[1,2,30]
[4,5,60]

columns :: (Unbox a, Unbox b) => IndexedTraversal Int (UArray V2 a) (UArray V2 b) (Vector a) (Vector b) Source #

Indexed traversal over the columns of a matrix. Unlike rows, each column is a new separate vector.

>>> traverseOf_ columns print m
[1,4]
[2,5]
[3,6]
>>> traverseOf_ rows print $ m & columns . indices odd . each .~ 0
[1,0,3]
[4,0,6]

The vectors should be the same size to be a valid traversal. If the vectors are different sizes, the number of rows in the new array will be the length of the smallest vector.

3D

ixPlane :: Unbox a => ALens' (V3 Int) (V2 Int) -> Int -> IndexedTraversal' Int (UArray V3 a) (UArray V2 a) Source #

Traversal over a single plane of a 3D array given a lens onto that plane (like _xy, _yz, _zx).

planes :: (Unbox a, Unbox b) => ALens' (V3 Int) (V2 Int) -> IndexedTraversal Int (UArray V3 a) (UArray V3 b) (UArray V2 a) (UArray V2 b) Source #

Traversal over all planes of 3D array given a lens onto that plane (like _xy, _yz, _zx).

flattenPlane :: (Unbox a, Unbox b) => ALens' (V3 Int) (V2 Int) -> (Vector a -> b) -> UArray V3 a -> UArray V2 b Source #

Flatten a plane by reducing a vector in the third dimension to a single value.

Ordinals

unsafeOrdinals :: (Unbox a, Shape f) => [f Int] -> IndexedTraversal' (f Int) (UArray f a) a Source #

This Traversal should not have any duplicates in the list of indices.

Mutable

type UMArray = MArray MVector Source #

Unboxed mutable array.

thaw :: (PrimMonad m, Unbox a) => UArray f a -> m (UMArray f (PrimState m) a) Source #

O(n) Yield an immutable copy of the mutable array.

freeze :: (PrimMonad m, Unbox a) => UMArray f (PrimState m) a -> m (UArray f a) Source #

O(n) Yield a mutable copy of the immutable vector.

unsafeThaw :: (PrimMonad m, Unbox a) => UArray f a -> m (UMArray 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, Unbox a) => UMArray f (PrimState m) a -> m (UArray 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

data Delayed f a Source #

A delayed representation of an array. This useful for mapping over an array in parallel.

Instances

Instances details
Shape f => HasLayout f (Delayed f a) Source #

The size of the layout must remain the same or an error is thrown.

Instance details

Defined in Data.Dense.Base

Methods

layout :: Lens' (Delayed f a) (Layout f) Source #

Functor (Delayed f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

fmap :: (a -> b) -> Delayed f a -> Delayed f b #

(<$) :: a -> Delayed f b -> Delayed f a #

Shape f => Foldable (Delayed f) Source #

foldMap in parallel.

Instance details

Defined in Data.Dense.Base

Methods

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] #

null :: Delayed f a -> Bool #

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 #

sum :: Num a => Delayed f a -> a #

product :: Num a => Delayed f a -> a #

Shape f => Traversable (Delayed f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

traverse :: Applicative f0 => (a -> f0 b) -> Delayed f a -> f0 (Delayed f b) #

sequenceA :: Applicative f0 => Delayed f (f0 a) -> f0 (Delayed f a) #

mapM :: Monad m => (a -> m b) -> Delayed f a -> m (Delayed f b) #

sequence :: Monad m => Delayed f (m a) -> m (Delayed f a) #

Shape f => Apply (Delayed f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

(<.>) :: Delayed f (a -> b) -> Delayed f a -> Delayed f b #

(.>) :: Delayed f a -> Delayed f b -> Delayed f b #

(<.) :: Delayed f a -> Delayed f b -> Delayed f a #

liftF2 :: (a -> b -> c) -> Delayed f a -> Delayed f b -> Delayed f c #

Shape f => Metric (Delayed f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

dot :: Num a => Delayed f a -> Delayed f a -> a #

quadrance :: Num a => Delayed f a -> a #

qd :: Num a => Delayed f a -> Delayed f a -> a #

distance :: Floating a => Delayed f a -> Delayed f a -> a #

norm :: Floating a => Delayed f a -> a #

signorm :: Floating a => Delayed f a -> Delayed f a #

Shape f => Additive (Delayed f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

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 # 
Instance details

Defined in Data.Dense.Base

Methods

imap :: (f Int -> a -> b) -> Delayed f a -> Delayed f b #

imapped :: IndexedSetter (f Int) (Delayed f a) (Delayed f b) a b #

Shape f => FoldableWithIndex (f Int) (Delayed f) Source #

ifoldMap in parallel.

Instance details

Defined in Data.Dense.Base

Methods

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 # 
Instance details

Defined in Data.Dense.Base

Methods

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 # 
Instance details

Defined in Data.Dense.Base

Methods

showsPrec :: Int -> Delayed f a -> ShowS #

show :: Delayed f a -> String #

showList :: [Delayed f a] -> ShowS #

Shape f => Ixed (Delayed f a) Source # 
Instance details

Defined in Data.Dense.Base

Methods

ix :: Index (Delayed f a) -> Traversal' (Delayed f a) (IxValue (Delayed f a)) #

Shape f => AsEmpty (Delayed f a) Source # 
Instance details

Defined in Data.Dense.Base

Methods

_Empty :: Prism' (Delayed f a) () #

Shape f => Each (Delayed f a) (Delayed f b) a b Source # 
Instance details

Defined in Data.Dense.Base

Methods

each :: Traversal (Delayed f a) (Delayed f b) a b #

type Index (Delayed f a) Source # 
Instance details

Defined in Data.Dense.Base

type Index (Delayed f a) = f Int
type IxValue (Delayed f a) Source # 
Instance details

Defined in Data.Dense.Base

type IxValue (Delayed f a) = a

Generating delayed

delayed :: (Unbox a, Unbox b, Shape f, Shape k) => Iso (UArray f a) (UArray k b) (Delayed f a) (Delayed k b) Source #

Isomorphism between an array and its delayed representation. Conversion to the array is done in parallel.

seqDelayed :: (Unbox a, Unbox b, Shape f, Shape k) => Iso (UArray f a) (UArray k b) (Delayed f a) (Delayed k b) Source #

Isomorphism between an array and its delayed representation. Conversion to the array is done in sequence.

delay :: (Unbox a, Shape f) => UArray f a -> Delayed f a Source #

Turn a material array into a delayed one with the same shape.

manifest :: (Unbox a, Shape f) => Delayed f a -> UArray f a Source #

Parallel manifestation of a delayed array into a material one.

seqManifest :: (Unbox a, Shape f) => Delayed f a -> UArray f a Source #

Sequential manifestation of a delayed array.

genDelayed :: Layout f -> (f Int -> a) -> Delayed f a Source #

Generate a Delayed array using the given Layout and construction function.

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.

affirm :: (Shape f, Unbox a) => Delayed f a -> Delayed f a Source #

manifest an array to a UArray and delay again.

seqAffirm :: (Shape f, Unbox a) => Delayed f a -> Delayed f a Source #

seqManifest an array to a UArray and delay again.

Focused

data Focused f a Source #

A delayed representation of an array with a focus on a single element. This element is the target of extract.

Instances

Instances details
Shape f => HasLayout f (Focused f a) Source #

The size of the layout must remain the same or an error is thrown.

Instance details

Defined in Data.Dense.Base

Methods

layout :: Lens' (Focused f a) (Layout f) Source #

Functor (Focused f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

fmap :: (a -> b) -> Focused f a -> Focused f b #

(<$) :: a -> Focused f b -> Focused f a #

Shape f => Foldable (Focused f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

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] #

null :: Focused f a -> Bool #

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 #

sum :: Num a => Focused f a -> a #

product :: Num a => Focused f a -> a #

Shape f => Traversable (Focused f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

traverse :: Applicative f0 => (a -> f0 b) -> Focused f a -> f0 (Focused f b) #

sequenceA :: Applicative f0 => Focused f (f0 a) -> f0 (Focused f a) #

mapM :: Monad m => (a -> m b) -> Focused f a -> m (Focused f b) #

sequence :: Monad m => Focused f (m a) -> m (Focused f a) #

Shape f => Comonad (Focused f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

extract :: Focused f a -> a #

duplicate :: Focused f a -> Focused f (Focused f a) #

extend :: (Focused f a -> b) -> Focused f a -> Focused f b #

Shape f => Extend (Focused f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

duplicated :: Focused f a -> Focused f (Focused f a) #

extended :: (Focused f a -> b) -> Focused f a -> Focused f b #

Shape f => ComonadStore (f Int) (Focused f) Source # 
Instance details

Defined in Data.Dense.Base

Methods

pos :: Focused f a -> f Int #

peek :: f Int -> Focused f a -> a #

peeks :: (f Int -> f Int) -> Focused f a -> a #

seek :: f Int -> Focused f a -> Focused f a #

seeks :: (f Int -> f Int) -> Focused f a -> Focused f a #

experiment :: Functor f0 => (f Int -> f0 (f Int)) -> Focused f a -> f0 a #

Shape f => FunctorWithIndex (f Int) (Focused f) Source #

Index relative to focus.

Instance details

Defined in Data.Dense.Base

Methods

imap :: (f Int -> a -> b) -> Focused f a -> Focused f b #

imapped :: IndexedSetter (f Int) (Focused f a) (Focused f b) a b #

Shape f => FoldableWithIndex (f Int) (Focused f) Source #

Index relative to focus.

Instance details

Defined in Data.Dense.Base

Methods

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.

Instance details

Defined in Data.Dense.Base

Methods

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 # 
Instance details

Defined in Data.Dense.Base

Methods

showsPrec :: Int -> Focused f a -> ShowS #

show :: Focused f a -> String #

showList :: [Focused f a] -> ShowS #

Shape f => Ixed (Focused f a) Source #

Index relative to focus.

Instance details

Defined in Data.Dense.Base

Methods

ix :: Index (Focused f a) -> Traversal' (Focused f a) (IxValue (Focused f a)) #

type Index (Focused f a) Source # 
Instance details

Defined in Data.Dense.Base

type Index (Focused f a) = f Int
type IxValue (Focused f a) Source # 
Instance details

Defined in Data.Dense.Base

type IxValue (Focused f a) = a

Generating focused

focusOn :: f Int -> Delayed f a -> Focused f a Source #

Focus on a particular element of a delayed array.

unfocus :: Focused f a -> Delayed f a Source #

Discard the focus to retrieve the delayed array.

unfocused :: IndexedLens (f Int) (Focused f a) (Focused f b) (Delayed f a) (Delayed f b) Source #

Indexed lens onto the delayed array, indexed at the focus.

extendFocus :: Shape f => (Focused f a -> b) -> Delayed f a -> Delayed f b Source #

Modify a Delayed array by extracting a value from a Focused each point.

Focus location

locale :: ComonadStore s w => Lens' (w a) s Source #

Lens onto the position of a ComonadStore.

locale :: Lens' (Focused l a) (l Int)

shiftFocus :: Applicative f => f Int -> Focused f a -> Focused f a Source #

Focus on a neighbouring element, relative to the current focus.