-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Efficient multidimensional arrays
--
-- This library provides efficient multidimensional arrays.
--
-- In general all operations are (highly) unsafe, no bounds-checking or
-- other sanity-checking is performed. Operations are aimed toward
-- efficiency as much as possible. Goals of the library are to have
-- arrays according to three ideas: immutablemutable arrays,
-- strictlazy arrays, zero-based/lower-bound arrays. Zero-based
-- arrays save one addition on each access if the lower bound or the
-- array is always zero.
--
-- We have forked two repa modules: Shape and Index.
@package PrimitiveArray
@version 0.2.1.1
-- | Class of types that can be used as array shapes and indices.
module Data.Array.Repa.Shape
-- | Class of types that can be used as array shapes and indices.
class Eq sh => Shape sh
rank :: Shape sh => sh -> Int
zeroDim :: Shape sh => sh
unitDim :: Shape sh => sh
intersectDim :: Shape sh => sh -> sh -> sh
addDim :: Shape sh => sh -> sh -> sh
size :: Shape sh => sh -> Int
sizeIsValid :: Shape sh => sh -> Bool
toIndex :: Shape sh => sh -> sh -> Int
fromIndex :: Shape sh => sh -> Int -> sh
inShapeRange :: Shape sh => sh -> sh -> sh -> Bool
listOfShape :: Shape sh => sh -> [Int]
shapeOfList :: Shape sh => [Int] -> sh
deepSeq :: Shape sh => sh -> a -> a
-- | Check whether an index is a part of a given shape.
inShape :: Shape sh => sh -> sh -> Bool
-- | Nicely format a shape as a string
showShape :: Shape sh => sh -> String
-- | Index types.
module Data.Array.Repa.Index
-- | An index of dimension zero
data Z
Z :: Z
-- | Our index type, used for both shapes and indices.
data (:.) tail head
(:.) :: tail -> head -> :. tail head
type DIM0 = Z
type DIM1 = DIM0 :. Int
type DIM2 = DIM1 :. Int
type DIM3 = DIM2 :. Int
type DIM4 = DIM3 :. Int
type DIM5 = DIM4 :. Int
instance Show Z
instance Eq Z
instance Ord Z
instance (Show tail, Show head) => Show (tail :. head)
instance (Eq tail, Eq head) => Eq (tail :. head)
instance (Ord tail, Ord head) => Ord (tail :. head)
instance Shape sh => Shape (sh :. Int)
instance Shape Z
-- | Additional functions on shapes
module Data.ExtShape
-- | A number of additional operations that are useful together with
-- PrimitiveArrays.
class (Eq sh, Shape sh) => ExtShape sh
subDim :: ExtShape sh => sh -> sh -> sh
rangeList :: ExtShape sh => sh -> sh -> [sh]
instance ExtShape sh => ExtShape (sh :. Int)
instance ExtShape Z
-- | Vastly extended primitive arrays. Some basic ideas are now modeled
-- after the vector package, especially the monadic mutable / pure
-- immutable array system. There are eight flavors of arrays among three
-- axes: mutable/pure + boxedunboxed + zero-basedlower-bound.
--
-- NOTE all operations in MPrimArrayOps and PrimArrayOps are highly
-- unsafe. No bounds-checking is performed at all.
module Data.PrimitiveArray
-- | The core set of operations for monadic arrays.
class (Shape sh, ExtShape sh) => MPrimArrayOps marr sh elm
boundsM :: MPrimArrayOps marr sh elm => marr s sh elm -> (sh, sh)
fromListM :: (MPrimArrayOps marr sh elm, PrimMonad m) => sh -> sh -> [elm] -> m (marr (PrimState m) sh elm)
newM :: (MPrimArrayOps marr sh elm, PrimMonad m) => sh -> sh -> m (marr (PrimState m) sh elm)
newWithM :: (MPrimArrayOps marr sh elm, PrimMonad m) => sh -> sh -> elm -> m (marr (PrimState m) sh elm)
readM :: (MPrimArrayOps marr sh elm, PrimMonad m) => marr (PrimState m) sh elm -> sh -> m elm
writeM :: (MPrimArrayOps marr sh elm, PrimMonad m) => marr (PrimState m) sh elm -> sh -> elm -> m ()
-- | Used to connect each immutable array with one mutable array.
-- | The core set of functions on immutable arrays.
class (Shape sh, ExtShape sh, MPrimArrayOps (MutArray arr) sh elm) => PrimArrayOps arr sh elm
bounds :: PrimArrayOps arr sh elm => arr sh elm -> (sh, sh)
freeze :: (PrimArrayOps arr sh elm, PrimMonad m) => MutArray arr (PrimState m) sh elm -> m (arr sh elm)
index :: PrimArrayOps arr sh elm => arr sh elm -> sh -> elm
-- | Infix index operator. Performs minimal bounds-checking using assert in
-- non-optimized code.
(!) :: PrimArrayOps arr sh elm => arr sh elm -> sh -> elm
-- | Returns true if the index is valid for the array.
inBoundsM :: MPrimArrayOps marr sh elm => marr s sh elm -> sh -> Bool
-- | Given two arrays with the same dimensionality, their respective
-- starting index, and how many steps to go in each dimension (in terms
-- of a dimension again), determine if the multidimensional slices have
-- the same value at all positions
--
-- TODO specialize for DIM1 (and maybe higher dim's) to use memcmp
sliceEq :: (Eq elm, PrimArrayOps arr sh elm) => arr sh elm -> sh -> arr sh elm -> sh -> sh -> Bool
-- | Construct a mutable primitive array from a lower and an upper bound, a
-- default element, and a list of associations.
fromAssocsM :: (PrimMonad m, MPrimArrayOps marr sh elm) => sh -> sh -> elm -> [(sh, elm)] -> m (marr (PrimState m) sh elm)
-- | Return all associations from an array.
assocs :: PrimArrayOps arr sh elm => arr sh elm -> [(sh, elm)]
-- | Creates an immutable array from lower and upper bounds and a complete
-- list of elements.
fromList :: PrimArrayOps arr sh elm => sh -> sh -> [elm] -> arr sh elm
-- | Creates an immutable array from lower and upper bounds, a default
-- element, and a list of associations.
fromAssocs :: PrimArrayOps arr sh elm => sh -> sh -> elm -> [(sh, elm)] -> arr sh elm
-- | Determines if an index is valid for a given immutable array.
inBounds :: PrimArrayOps arr sh elm => arr sh elm -> sh -> Bool
-- | Returns all elements of an immutable array as a list.
toList :: PrimArrayOps arr sh elm => arr sh elm -> [elm]
-- | Strict, unboxed arrays of primitive type.
module Data.PrimitiveArray.Unboxed.Zero
-- | Monadic arrays of primitive type.
data MArr0 s sh elm
MArr0 :: !sh -> {-# UNPACK #-} !MutableByteArray s -> MArr0 s sh elm
-- | Immutable arrays of primitive type.
data Arr0 sh elm
Arr0 :: !sh -> {-# UNPACK #-} !ByteArray -> Arr0 sh elm
instance (Shape sh, ExtShape sh, Prim elm) => PrimArrayOps Arr0 sh elm
instance (Shape sh, ExtShape sh, Prim elm) => MPrimArrayOps MArr0 sh elm
-- | Boxed, primitive arrays. A good use-case is to store boxed or unboxed
-- vectors.
module Data.PrimitiveArray.Zero
-- | Monadic arrays of primitive type.
data MArr0 s sh elm
MArr0 :: !sh -> {-# UNPACK #-} !MutableArray s elm -> MArr0 s sh elm
-- | Immutable arrays of primitive type.
data Arr0 sh elm
Arr0 :: !sh -> {-# UNPACK #-} !Array elm -> Arr0 sh elm
instance (Shape sh, ExtShape sh) => PrimArrayOps Arr0 sh elm
instance (Shape sh, ExtShape sh) => MPrimArrayOps MArr0 sh elm