See the repa-examples package for examples.

More information is also at http://trac.haskell.org/repa

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.Shape
- module Data.Array.Repa.Index
- module Data.Array.Repa.Slice
- data Array sh a
- fromUArray :: Shape sh => sh -> Array a -> Array sh a
- fromFunction :: Shape sh => sh -> (sh -> a) -> Array sh a
- unit :: Elt a => a -> Array Z a
- extent :: Array sh a -> sh
- delay :: (Shape sh, Elt a) => Array sh a -> (sh, sh -> a)
- toUArray :: (Shape sh, Elt a) => Array sh a -> Array a
- index :: forall sh a. (Shape sh, Elt a) => Array sh a -> sh -> a
- (!:) :: forall sh a. (Shape sh, Elt a) => Array sh a -> sh -> a
- toScalar :: Elt a => Array Z a -> a
- force :: (Shape sh, Elt a) => Array sh a -> Array sh a
- deepSeqArray :: Shape sh => Array sh a -> b -> b
- fromList :: (Shape sh, Elt a) => sh -> [a] -> Array sh a
- toList :: (Shape sh, Elt a) => Array sh a -> [a]
- 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
- (+:+) :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a
- transpose :: (Shape sh, Elt a) => Array ((sh :. Int) :. Int) a -> Array ((sh :. Int) :. Int) a
- replicate :: (Slice sl, Shape (FullShape sl), Shape (SliceShape sl), Elt e) => sl -> Array (SliceShape sl) e -> Array (FullShape sl) e
- slice :: (Slice sl, Shape (FullShape sl), Shape (SliceShape sl), Elt e) => Array (FullShape sl) e -> sl -> Array (SliceShape sl) e
- backpermute :: forall sh sh' a. (Shape sh, Shape sh', Elt a) => sh' -> (sh' -> sh) -> Array sh a -> Array sh' a
- backpermuteDft :: forall sh sh' a. (Shape sh, Shape sh', Elt a) => Array sh' a -> (sh' -> Maybe sh) -> Array sh a -> Array sh' a
- map :: (Shape sh, Elt a, Elt b) => (a -> b) -> Array sh a -> Array sh b
- zipWith :: (Shape sh, Elt a, Elt b, Elt c) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh c
- fold :: (Shape sh, Elt a) => (a -> a -> a) -> a -> Array (sh :. Int) a -> Array sh a
- foldAll :: (Shape sh, Elt a) => (a -> a -> a) -> a -> Array sh a -> a
- sum :: (Shape sh, Elt a, Num a) => Array (sh :. Int) a -> Array sh a
- sumAll :: (Shape sh, Elt a, Num a) => Array sh a -> a
- traverse :: forall sh sh' a b. (Shape sh, Shape sh', Elt a) => Array sh a -> (sh -> sh') -> ((sh -> a) -> sh' -> b) -> Array sh' b
- traverse2 :: forall sh sh' sh'' a b c. (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
- traverse3 :: forall sh1 sh2 sh3 sh4 a b c d. (Shape sh1, Shape sh2, Shape sh3, Shape sh4, Elt a, Elt b, Elt c, Elt d) => Array sh1 a -> Array sh2 b -> Array sh3 c -> (sh1 -> sh2 -> sh3 -> sh4) -> ((sh1 -> a) -> (sh2 -> b) -> (sh3 -> c) -> sh4 -> d) -> Array sh4 d
- traverse4 :: forall sh1 sh2 sh3 sh4 sh5 a b c d e. (Shape sh1, Shape sh2, Shape sh3, Shape sh4, Shape sh5, Elt a, Elt b, Elt c, Elt d, Elt e) => Array sh1 a -> Array sh2 b -> Array sh3 c -> Array sh4 d -> (sh1 -> sh2 -> sh3 -> sh4 -> sh5) -> ((sh1 -> a) -> (sh2 -> b) -> (sh3 -> c) -> (sh4 -> d) -> sh5 -> e) -> Array sh5 e
- interleave2 :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a
- interleave3 :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a
- interleave4 :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a
- arbitrarySmallArray :: (Shape sh, Elt a, Arbitrary sh, Arbitrary a) => Int -> Gen (Array (sh :. Int) a)
- props_DataArrayRepa :: [(String, Property)]

# Documentation

module Data.Array.Repa.Shape

module Data.Array.Repa.Index

module Data.Array.Repa.Slice

Possibly delayed arrays.

# Constructors

fromUArray :: Shape sh => sh -> Array a -> Array sh aSource

fromFunction :: Shape sh => sh -> (sh -> a) -> Array sh aSource

Create a `Delayed`

array from a function.

# Projections

toUArray :: (Shape sh, Elt a) => Array sh a -> Array aSource

Convert an array to an unboxed `Array`

, forcing it if required.
The elements come out in row-major order.

(!:) :: forall sh a. (Shape sh, Elt a) => Array sh a -> sh -> aSource

Get an indexed element from an array.

OBLIGATION: The index must be within the array.

inRange zeroDim (shape arr) ix == True

# Basic Operations

force :: (Shape sh, Elt a) => Array sh a -> Array sh aSource

Force an array, so that it becomes `Manifest`

.

deepSeqArray :: Shape sh => Array sh a -> b -> bSource

Ensure an array's structure is fully evaluated.
This evaluates the extent and outer constructor, but does not `force`

the elements.

# Conversion

# Index space transformations

reshape :: (Shape sh, Shape sh', Elt a) => Array sh a -> sh' -> Array sh' aSource

Impose a new shape on the elements of an array.
The new extent must be the same size as the original, else `error`

.

append :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) aSource

(+:+) :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) aSource

Append two arrays.

OBLIGATION: The higher dimensions of both arrays must have the same extent.

tail (listOfShape (shape arr1)) == tail (listOfShape (shape arr2))

transpose :: (Shape sh, Elt a) => Array ((sh :. Int) :. Int) a -> Array ((sh :. Int) :. Int) aSource

Transpose the lowest two dimensions of an array. Transposing an array twice yields the original.

replicate :: (Slice sl, Shape (FullShape sl), Shape (SliceShape sl), Elt e) => sl -> Array (SliceShape sl) e -> Array (FullShape sl) eSource

Replicate an array, according to a given slice specification.

slice :: (Slice sl, Shape (FullShape sl), Shape (SliceShape sl), Elt e) => Array (FullShape sl) e -> sl -> Array (SliceShape sl) eSource

Take a slice from an array, according to a given specification.

:: forall sh sh' a . (Shape sh, Shape sh', Elt a) | |

=> sh' | Extent of result array. |

-> (sh' -> sh) | Function mapping each index in the result array to an index of the source array. |

-> Array sh a | Source array. |

-> Array sh' a |

Backwards permutation of an array's elements. The result array has the same extent as the original.

:: forall sh sh' a . (Shape sh, Shape sh', Elt a) | |

=> Array sh' a | Default values ( |

-> (sh' -> Maybe sh) | Function mapping each index in the result array to an index in the source array. |

-> Array sh a | Source array. |

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

)

# Structure preserving operations

map :: (Shape sh, Elt a, Elt b) => (a -> b) -> Array sh a -> Array sh bSource

Apply a worker function to each element of an array, yielding a new array with the same extent.

zipWith :: (Shape sh, Elt a, Elt b, Elt c) => (a -> b -> c) -> Array sh a -> Array sh b -> Array sh cSource

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.

# Reductions

fold :: (Shape sh, Elt a) => (a -> a -> a) -> a -> Array (sh :. Int) a -> Array sh aSource

Fold the innermost dimension of an array.
Combine this with `transpose`

to fold any other dimension.

foldAll :: (Shape sh, Elt a) => (a -> a -> a) -> a -> Array sh a -> aSource

Fold all the elements of an array.

sum :: (Shape sh, Elt a, Num a) => Array (sh :. Int) a -> Array sh aSource

Sum the innermost dimension of an array.

# Generic traversal

:: forall sh sh' a b . (Shape sh, Shape sh', Elt a) | |

=> Array sh a | Source array. |

-> (sh -> sh') | Function to produce the extent of the result. |

-> ((sh -> a) -> sh' -> b) | Function to produce elements of the result. It is passed a lookup function to get elements of the source. |

-> Array sh' b |

Unstructured traversal.

:: forall sh sh' sh'' a b c . (Shape sh, Shape sh', Shape sh'', Elt a, Elt b, Elt c) | |

=> Array sh a | First source array. |

-> Array sh' b | Second source array. |

-> (sh -> sh' -> sh'') | Function to produce the extent of the result. |

-> ((sh -> a) -> (sh' -> b) -> sh'' -> c) | Function to produce elements of the result. It is passed lookup functions to get elements of the source arrays. |

-> Array sh'' c |

Unstructured traversal over two arrays at once.

traverse3 :: forall sh1 sh2 sh3 sh4 a b c d. (Shape sh1, Shape sh2, Shape sh3, Shape sh4, Elt a, Elt b, Elt c, Elt d) => Array sh1 a -> Array sh2 b -> Array sh3 c -> (sh1 -> sh2 -> sh3 -> sh4) -> ((sh1 -> a) -> (sh2 -> b) -> (sh3 -> c) -> sh4 -> d) -> Array sh4 dSource

Unstructured traversal over three arrays at once.

traverse4 :: forall sh1 sh2 sh3 sh4 sh5 a b c d e. (Shape sh1, Shape sh2, Shape sh3, Shape sh4, Shape sh5, Elt a, Elt b, Elt c, Elt d, Elt e) => Array sh1 a -> Array sh2 b -> Array sh3 c -> Array sh4 d -> (sh1 -> sh2 -> sh3 -> sh4 -> sh5) -> ((sh1 -> a) -> (sh2 -> b) -> (sh3 -> c) -> (sh4 -> d) -> sh5 -> e) -> Array sh5 eSource

Unstructured traversal over four arrays at once.

# Interleaving

interleave2 :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) aSource

Interleave the elments of two arrays.
All the input arrays must have the same extent, else `error`

.
The lowest dimenion of the result array is twice the size of the inputs.

interleave2 a1 a2 b1 b2 => a1 b1 a2 b2 a3 a4 b3 b4 a3 b3 a4 b4

interleave3 :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) aSource

Interleave the elments of three arrays.

interleave4 :: (Shape sh, Elt a) => Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) a -> Array (sh :. Int) aSource

Interleave the elments of four arrays.

# Testing

arbitrarySmallArray :: (Shape sh, Elt a, Arbitrary sh, Arbitrary a) => Int -> Gen (Array (sh :. Int) a)Source

Create an arbitrary small array, restricting the size of each of the dimensions to some value.

props_DataArrayRepa :: [(String, Property)]Source

QuickCheck properties for this module and its children.