-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | High performance, regular, shape polymorphic parallel arrays. -- -- NOTE: You must use the GHC head branch > 6.13.20100309 to get -- decent performance. Repa provides high performance, regular, -- multi-dimensional, shape polymorphic parallel arrays. All numeric data -- is stored unboxed. Functions written with the Repa combinators are -- automatically parallel provided you supply +RTS -Nwhatever on the -- command line when running the program. @package repa @version 1.0.0.0 -- | 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 dim :: (Shape sh) => sh -> Int zeroDim :: (Shape sh) => sh unitDim :: (Shape sh) => sh intersectDim :: (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 inRange :: (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 -- | 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 -- | Generate an aribrary shape that does not have 0's for any component. arbitraryShape :: (Shape sh, Arbitrary sh) => Gen (sh :. Int) -- | Generate an arbitrary shape where each dimension is more than zero, -- but less than a specific value. arbitrarySmallShape :: (Shape sh, Arbitrary sh) => Int -> Gen (sh :. Int) -- | QuickCheck properties for this module. props_DataArrayRepaIndex :: [(String, Property)] 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 Show Z instance Eq Z instance Ord Z instance (Shape sh, Arbitrary sh) => Arbitrary (sh :. Int) instance Arbitrary Z instance (Shape sh) => Shape (sh :. Int) instance Shape Z -- | Index space transformation between arrays and slices. module Data.Array.Repa.Slice -- | Select all indices at a certain position. data All All :: All -- | Place holder for any possible shape. data Any sh Any :: Any sh -- | Map a type of the index in the full shape, to the type of the index in -- the slice. -- | Map the type of an index in the slice, to the type of the index in the -- full shape. -- | Class of index types that can map to slices. class Slice ss sliceOfFull :: (Slice ss) => ss -> FullShape ss -> SliceShape ss fullOfSlice :: (Slice ss) => ss -> SliceShape ss -> FullShape ss instance (Slice sl) => Slice (sl :. All) instance (Slice sl) => Slice (sl :. Int) instance Slice (Any sh) instance Slice Z -- | See the repa-examples package for examples. -- -- More information is also at -- http:code.haskell.orgtracrepa -- -- NOTE: To get decent performance you must use GHC head branch > -- 6.13.20100309. -- -- WARNING: Most of the functions that operate on indices don't perform -- bounds checks. Doing these checks would interfere with code -- optimisation and reduce performance. Indexing outside arrays, or -- failing to meet the stated obligations will likely cause heap -- corruption. module Data.Array.Repa -- | Possibly delayed arrays. data Array sh a -- | An array represented as some concrete unboxed data. Manifest :: sh -> (Array a) -> Array sh a -- | An array represented as a function that computes each element. Delayed :: sh -> (sh -> a) -> Array sh a -- | Create a Manifest array from an unboxed Array. The -- elements are in row-major order. fromUArray :: (Shape sh) => sh -> Array a -> Array sh a -- | Create a Delayed array from a function. fromFunction :: (Shape sh) => sh -> (sh -> a) -> Array sh a -- | Wrap a scalar into a singleton array. unit :: (Elt a) => a -> Array Z a -- | Take the extent of an array. extent :: Array sh a -> sh -- | Unpack an array into delayed form. delay :: (Shape sh, Elt a) => Array sh a -> (sh, sh -> a) -- | Convert an array to an unboxed Array, forcing it if required. -- The elements come out in row-major order. toUArray :: (Shape sh, Elt a) => Array sh a -> Array a index :: (Shape sh, Elt a) => Array sh a -> sh -> a -- | Get an indexed element from an array. -- -- OBLIGATION: The index must be within the array. -- --
--   inRange zeroDim (shape arr) ix == True
--   
(!:) :: (Shape sh, Elt a) => Array sh a -> sh -> a -- | Take the scalar value from a singleton array. toScalar :: (Elt a) => Array Z a -> a -- | Force an array, so that it becomes Manifest. force :: (Shape sh, Elt a) => Array sh a -> Array sh a isManifest :: Array sh a -> Array sh a -- | Ensure an array's structure is fully evaluated. This evaluates the -- extent and outer constructor, but does not force the elements. deepSeqArray :: (Shape sh) => Array sh a -> b -> b -- | Convert a list to an array. The length of the list must be exactly the -- size of the extent given, else error. fromList :: (Shape sh, Elt a) => sh -> [a] -> Array sh a -- | Convert an array to a list. toList :: (Shape sh, Elt a) => Array sh a -> [a] -- | Impose a new shape on the elements of an array. The new extent must be -- the same size as the original, else error. reshape :: (Shape sh, Shape sh', Elt a) => Array sh a -> sh' -> Array sh' a append :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a -- | Append two arrays. -- -- OBLIGATION: The higher dimensions of both arrays must have the same -- extent. -- --
--   tail (listOfShape (shape arr1)) == tail (listOfShape (shape arr2))
--   
(+:+) :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a -- | Transpose the lowest two dimensions of an array. Transposing an array -- twice yields the original. transpose :: (Shape sh, Elt a) => Array ((sh :. Int) :. Int) a -> Array ((sh :. Int) :. Int) a -- | Replicate an array, according to a given slice specification. replicate :: (Slice sl, Shape (FullShape sl), Shape (SliceShape sl), Elt e) => sl -> Array (SliceShape sl) e -> Array (FullShape sl) e -- | Take a slice from an array, according to a given specification. slice :: (Slice sl, Shape (FullShape sl), Shape (SliceShape sl), Elt e) => Array (FullShape sl) e -> sl -> Array (SliceShape sl) e -- | Backwards permutation of an array's elements. The result array has the -- same extent as the original. backpermute :: (Shape sh, Shape sh', Elt a) => sh' -> (sh' -> sh) -> Array sh a -> Array sh' a -- | Default backwards permutation of an array's elements. If the function -- returns Nothing then the value at that index is taken from the -- default array (arrDft) backpermuteDft :: (Shape sh, Shape sh', Elt a) => Array sh' a -> (sh' -> Maybe sh) -> Array sh a -> Array sh' a -- | Apply a worker function to each element of an array, yielding a new -- array with the same extent. map :: (Shape sh, Elt a, Elt b) => (a -> b) -> Array sh a -> Array sh b -- | Combine two arrays, element-wise, with a binary operator. If the -- extent of the two array arguments differ, then the resulting array's -- extent is their intersection. zipWith :: (Shape sh, Elt a, Elt b, Elt c) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c -- | Fold the innermost dimension of an array. Combine this with -- transpose to fold any other dimension. fold :: (Shape sh, Elt a) => (a -> a -> a) -> a -> Array (sh :. Int) a -> Array sh a -- | Sum the innermost dimension of an array. sum :: (Shape sh, Elt a, Num a) => Array (sh :. Int) a -> Array sh a -- | Sum all the elements of an array. sumAll :: (Shape sh, Elt a, Num a) => Array sh a -> a -- | Unstructured traversal. traverse :: (Shape sh, Shape sh', Elt a) => Array sh a -> (sh -> sh') -> ((sh -> a) -> sh' -> b) -> Array sh' b -- | Unstructured traversal over two arrays at once. traverse2 :: (Shape sh, Shape sh', Shape sh'', Elt a, Elt b, Elt c) => Array sh a -> Array sh' b -> (sh -> sh' -> sh'') -> ((sh -> a) -> (sh' -> b) -> (sh'' -> c)) -> Array sh'' c -- | Create an arbitrary small array, restricting the size of each of the -- dimensions to some value. arbitrarySmallArray :: (Shape sh, Elt a, Arbitrary sh, Arbitrary a) => Int -> Gen (Array (sh :. Int) a) -- | QuickCheck properties for this module and its children. props_DataArrayRepa :: [(String, Property)] instance (Shape sh, Elt a, Num a) => Num (Array sh a) instance (Shape sh, Elt a, Eq a) => Eq (Array sh a) instance (Shape sh, Elt a, Show a) => Show (Array sh a)