-- 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.
@package PrimitiveArray
@version 0.5.0.0
-- | Additional functions on shapes
module Data.Array.Repa.ExtShape
-- | A number of additional operations that are useful together with
-- PrimitiveArrays.
class ExtShape sh
subDim :: ExtShape sh => sh -> sh -> sh
rangeList :: ExtShape sh => sh -> sh -> [sh]
instance ExtShape sh => ExtShape (sh :. Int)
instance ExtShape Z
-- | A Repa-compatible index of points in multi-dimensional space. A point
-- represents the index of a left- or right-linear grammar.
module Data.Array.Repa.Index.Point
stage :: [Char]
newtype Point
Point :: Int -> Point
instance Eq Point
instance Ord Point
instance Show Point
instance Arbitrary z => Arbitrary (z :. Point)
instance Arbitrary Point
instance NFData Point
instance ExtShape sh => ExtShape (sh :. Point)
instance Shape sh => Shape (sh :. Point)
-- | Subwords span upper triangular tables. A subword (i,j) is legal iff
-- i<=j.
--
-- NOTE Using more complicated shapes has a number of benefits. We don't
-- need to specify triangular or rectangular tables anymore. A
-- rectangular one-dimensional table with a subword as shape actually
-- does create space as required for subwords.
--
-- TODO subword indexing is currently hardcoded to be zero-based. See
-- subwordIndex.
--
-- TODO consider replacing (quot 2) with (shiftR 1)
--
-- TODO all the QuickCheck stuff is missing
module Data.Array.Repa.Index.Subword
stage :: [Char]
-- | A subword wraps a simple pair.
--
-- Subwords always yield the upper-triangular part of a rect-angular
-- array. This gives the quite curious effect that (0,N) points to the
-- `largest' index, while (0,0) and (N,N) both point to the
-- smallest. We do, however, use (0,0) as the smallest as (0,k) gives
-- successively smaller upper triangular parts.
newtype Subword
Subword :: (Int :. Int) -> Subword
subword :: Int -> Int -> Subword
-- | triangular numbers
--
-- A000217
triangularNumber :: Int -> Int
-- | Size of an upper triangle starting at i and ending at
-- j. (0,N) what be the normal thing to use.
upperTri :: Subword -> Int
-- | Subword indexing. Given the longest subword and the current subword,
-- calculate a linear index [0,..]. (l,n) in this case
-- means lower bound, length n. And (i,j) is the
-- normal index.
--
-- TODO probably doesn't work right with non-zero base ?!
subwordIndex :: Subword -> Subword -> Int
subwordFromIndex :: Subword -> Int -> Subword
instance Arbitrary z => Arbitrary (z :. Subword)
instance Arbitrary Subword
instance NFData Subword
instance ExtShape sh => ExtShape (sh :. Subword)
instance Shape sh => Shape (sh :. Subword)
instance Vector Vector Subword
instance MVector MVector Subword
instance Unbox Subword
instance Eq Subword
instance Ord Subword
instance Show Subword
-- | Vastly extended primitive arrays. Some basic ideas are now modeled
-- after the vector package, especially the monadic mutable / pure
-- immutable array system.
--
-- NOTE all operations in MPrimArrayOps and PrimArrayOps are highly
-- unsafe. No bounds-checking is performed at all.
module Data.PrimitiveArray
-- | Mutable version of an array.
-- | The core set of operations for monadic arrays.
class (Shape sh, ExtShape sh) => MPrimArrayOps arr sh elm
boundsM :: MPrimArrayOps arr sh elm => MutArr m (arr sh elm) -> (sh, sh)
fromListM :: (MPrimArrayOps arr sh elm, PrimMonad m) => sh -> sh -> [elm] -> m (MutArr m (arr sh elm))
newM :: (MPrimArrayOps arr sh elm, PrimMonad m) => sh -> sh -> m (MutArr m (arr sh elm))
newWithM :: (MPrimArrayOps arr sh elm, PrimMonad m) => sh -> sh -> elm -> m (MutArr m (arr sh elm))
readM :: (MPrimArrayOps arr sh elm, PrimMonad m) => MutArr m (arr sh elm) -> sh -> m elm
writeM :: (MPrimArrayOps arr sh elm, PrimMonad m) => MutArr m (arr sh elm) -> sh -> elm -> m ()
-- | The core set of functions on immutable arrays.
class (Shape sh, ExtShape sh) => PrimArrayOps arr sh elm
bounds :: PrimArrayOps arr sh elm => arr sh elm -> (sh, sh)
freeze :: (PrimArrayOps arr sh elm, PrimMonad m) => MutArr m (arr sh elm) -> m (arr sh elm)
index :: PrimArrayOps arr sh elm => arr sh elm -> sh -> elm
class (Shape sh, ExtShape sh) => PrimArrayMap arr sh e e'
map :: PrimArrayMap arr sh e e' => (e -> e') -> arr sh e -> arr sh e'
-- | 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 :: (Monad m, MPrimArrayOps arr sh elm) => MutArr m (arr 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 arr sh elm) => sh -> sh -> elm -> [(sh, elm)] -> m (MutArr m (arr 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, MPrimArrayOps 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, MPrimArrayOps 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]
-- | Operations to fill primitive arrays. Arrays are combined just like
-- indices using Z and '(:.)'. This allows filling an unlimited
-- number of tables.
--
-- TODO make explicit in which order the tables are filled.
module Data.PrimitiveArray.FillTables
class UpperTriS m stack
upperTriS :: UpperTriS m stack => stack -> m ()
-- | Defines how a single index in a stack of arrays + evaluation functions
-- is handled.
class Stack m sh xs
writeStack :: Stack m sh xs => xs -> sh -> m ()
instance (PrimMonad m, Stack m Subword xs, MPrimArrayOps arr Subword e) => Stack m Subword (xs :. (MutArr m (arr Subword e), Subword -> m e))
instance Monad m => Stack m sh Z
instance (Monad m, MPrimArrayOps arr Subword e, Stack m Subword (xs :. MutArr m (arr Subword e))) => UpperTriS m (xs :. MutArr m (arr Subword e))
-- | Primitive arrays where the lower index is zero (or the equivalent of
-- zero for newtypes and enumerations).
module Data.PrimitiveArray.Zero
data Unboxed sh e
Unboxed :: !sh -> !(Vector e) -> Unboxed sh e
instance (Read sh, Read e, Unbox e) => Read (Unboxed sh e)
instance (Show sh, Show e, Unbox e) => Show (Unboxed sh e)
instance (Eq sh, Eq e, Unbox e) => Eq (Unboxed sh e)
instance (Shape sh, ExtShape sh, Unbox e, Unbox e') => PrimArrayMap Unboxed sh e e'
instance (Shape sh, ExtShape sh, Unbox elm) => PrimArrayOps Unboxed sh elm
instance (Shape sh, ExtShape sh, Unbox elm) => MPrimArrayOps Unboxed sh elm