uvector-0.1.1.1: Fast unboxed arrays with a flexible interface

Portabilitynon-portable (GADTS)
Stabilityinternal
MaintainerRoman Leshchinskiy <rl@cse.unsw.edu.au>

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

Synopsis

Array types and classes containing the admissable elements types

class UA e whereSource

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.

Associated Types

data UArr e Source

The basic array datatype.

data MUArr e :: * -> *Source

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.

class UAE e => UPrim e whereSource

Methods

mkUAPrim :: BUArr e -> UArr eSource

unUAPrim :: UArr e -> BUArr eSource

mkMUAPrim :: MBUArr s e -> MUArr e sSource

unMUAPrim :: MUArr e s -> MBUArr s eSource

Basic operations on parallel arrays

unitsU :: Int -> UArr ()Source

O(1). Yield an array of units.

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.

newDynU :: UA e => Int -> (forall s. MUArr e s -> ST s Int) -> UArr eSource

newDynResU :: UA e => Int -> (forall s. MUArr e s -> ST s (Int :*: r)) -> UArr e :*: rSource

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.

unsafeZipMU :: (UA a, UA b) => MUArr a s -> MUArr b s -> MUArr (a :*: b) sSource

Elementwise pairing of mutable arrays. This is an unsafe operation, as no copying is performed, so changes to the pair array will affect the original arrays, and vice versa.

unsafeUnzipMU :: (UA a, UA b) => MUArr (a :*: b) s -> MUArr a s :*: MUArr b sSource

Elementwise unpairing of mutable arrays. This is an unsafe operation, as no copying is performed, so changes to the unpaired arrays will affect the original, and vice versa.