Portability | non-portable (GADTS) |
---|---|
Stability | internal |
Maintainer | Roman Leshchinskiy <[email protected]> |
Data.Array.Vector.UArr
Contents
Description
Description --------------------------------------------------------------- This module defines unlifted arrays generically as a GADT.
Slicing is implemented by each BUArr
having the slicing information. A
possible alternative design would be to maintain this information in
UArr
, but not in the representations, but at the root. This may seem
attractive at first, but seems to be more disruptive without any real
benefits _ this is essentially, because we then need the slicing
information at each level; ie, also at the leafs where it is sufficient
using the current implementation.
Todo ----------------------------------------------------------------------
- class UA e where
- data UArr e
- data MUArr e :: * -> *
- lengthU :: UArr e -> Int
- indexU :: UArr e -> Int -> e
- sliceU :: UArr e -> Int -> Int -> UArr e
- lengthMU :: MUArr e s -> Int
- newMU :: Int -> ST s (MUArr e s)
- readMU :: MUArr e s -> Int -> ST s e
- writeMU :: MUArr e s -> Int -> e -> ST s ()
- copyMU :: MUArr e s -> Int -> UArr e -> ST s ()
- unsafeFreezeMU :: MUArr e s -> Int -> ST s (UArr e)
- memcpyMU :: MUArr e s -> MUArr e s -> Int -> ST s ()
- memcpyOffMU :: MUArr e s -> MUArr e s -> Int -> Int -> Int -> ST s ()
- memmoveOffMU :: MUArr e s -> MUArr e s -> Int -> Int -> Int -> ST s ()
- class UAE e => UPrim e where
- unitsU :: Int -> UArr ()
- zipU :: (UA a, UA b) => UArr a -> UArr b -> UArr (a :*: b)
- unzipU :: (UA a, UA b) => UArr (a :*: b) -> UArr a :*: UArr b
- fstU :: (UA a, UA b) => UArr (a :*: b) -> UArr a
- sndU :: (UA a, UA b) => UArr (a :*: b) -> UArr b
- newU :: UA e => Int -> (forall s. MUArr e s -> ST s ()) -> UArr e
- newDynU :: UA e => Int -> (forall s. MUArr e s -> ST s Int) -> UArr e
- newDynResU :: UA e => Int -> (forall s. MUArr e s -> ST s (Int :*: r)) -> UArr e :*: r
- unsafeFreezeAllMU :: UA e => MUArr e s -> ST s (UArr e)
- unsafeZipMU :: (UA a, UA b) => MUArr a s -> MUArr b s -> MUArr (a :*: b) s
- unsafeUnzipMU :: (UA a, UA b) => MUArr (a :*: b) s -> MUArr a s :*: MUArr b s
Array types and classes containing the admissable elements types
This type class determines the types that can be elements immutable unboxed arrays. The representation type of these arrays is defined by way of an associated type. All representation-dependent functions are methods of this class.
Methods
lengthU :: UArr e -> IntSource
O(1). Yield the length of an unboxed array.
indexU :: UArr e -> Int -> eSource
O(1). Read an element from the array.
sliceU :: UArr e -> Int -> Int -> UArr eSource
O(1). sliceU
restricts access to a subrange of the original array
(no copying).
lengthMU :: MUArr e s -> IntSource
O(1). lengthMU
yields the length of a mutable unboxed array.
newMU :: Int -> ST s (MUArr e s)Source
O(1). newMU
allocates a mutable unboxed array of the specified length.
readMU :: MUArr e s -> Int -> ST s eSource
O(1). readMU
reads the element at the specified index of a mutable
unboxed array.
writeMU :: MUArr e s -> Int -> e -> ST s ()Source
O(1). writeMU
writes a new value to the specified index of a
mutable unboxed array.
copyMU :: MUArr e s -> Int -> UArr e -> ST s ()Source
O(n). copyMU
copies the contents of an immutable unboxed array into
a mutable one starting from the specified index.
unsafeFreezeMU :: MUArr e s -> Int -> ST s (UArr e)Source
O(1). unsafeFreezeMU
converts a prefix of a mutable array into an
immutable unboxed array, without copying. The mutable array must not be
mutated after this.
memcpyMU :: MUArr e s -> MUArr e s -> Int -> ST s ()Source
Copy a portion of one mutable array to a second.
memcpyOffMU :: MUArr e s -> MUArr e s -> Int -> Int -> Int -> ST s ()Source
Copy a portion of one mutable array to a second, beginning at the specified offsets for each.
memmoveOffMU :: MUArr e s -> MUArr e s -> Int -> Int -> Int -> ST s ()Source
Copy a portion of one mutable array to a second, beginning at the specified offsets for each. This operation is safe even if the source and destination are the same.
Instances
UA Bool | |
UA Char | |
UA Double | |
UA Float | |
UA Int | |
UA Int8 | |
UA Int16 | |
UA Int32 | |
UA Int64 | |
UA Word | |
UA Word8 | |
UA Word16 | |
UA Word32 | |
UA Word64 | |
UA () | Array operations on the unit representation. |
(Integral a, UA a) => UA (Ratio a) | |
(RealFloat a, UA a) => UA (Complex a) | |
(UA a, UA b) => UA (:*: a b) | Array operations on the pair representation. |
Basic operations on parallel arrays
zipU :: (UA a, UA b) => UArr a -> UArr b -> UArr (a :*: b)Source
O(1). Elementwise pairing of array elements.
N.B: The output will be as long as the first array (and will thus access past the end of the second array), unlike its List counterpart. This will not occur at the time zipU is called, but only after the resulting array is accessed.
unzipU :: (UA a, UA b) => UArr (a :*: b) -> UArr a :*: UArr bSource
O(1). Elementwise unpairing of array elements.
fstU :: (UA a, UA b) => UArr (a :*: b) -> UArr aSource
O(1). Yield the first components of an array of pairs.
sndU :: (UA a, UA b) => UArr (a :*: b) -> UArr bSource
O(1). Yield the second components of an array of pairs.
newU :: UA e => Int -> (forall s. MUArr e s -> ST s ()) -> UArr eSource
O(n). newU
constructs an immutable array of the given size by
performing the provided initialization function on a mutable representation
of the output array.
unsafeFreezeAllMU :: UA e => MUArr e s -> ST s (UArr e)Source
O(1). unsafeFreezeAllMU
converts an entire mutable array into an
immutable array, without copying. The mutable array must not be mutated
after this.