Permalink
Browse files

add documentation/example for slice

  • Loading branch information...
1 parent eb31416 commit c58fc196a8f0121e5c68fa8d1f7023eb8e23cd45 @rrnewton rrnewton committed Oct 10, 2012
Showing with 12 additions and 3 deletions.
  1. +12 −3 Data/Array/Accelerate/Language.hs
View
15 Data/Array/Accelerate/Language.hs
@@ -206,10 +206,19 @@ reshape = Acc $$ Reshape
-- Extraction of sub-arrays
-- ------------------------
--- | Index an array with a /generalised/ array index, supplied as the second
--- argument. The result is a new array (possibly a singleton) containing all
--- dimensions in their entirety.
+-- | Index an array with a /generalised/ array index, supplied as the
+-- second argument. The result is a new array (possibly a singleton)
+-- containing the selected dimensions (`All`s) in their entirety.
--
+-- This can be used to /cut out/ entire dimensions. The opposite of
+-- `replicate`. For example, if 'mat' is a two dimensional array, the
+-- following will select a specific row and yield a one dimensional
+-- result:
+--
+-- > slice mat (constant (Z :. (2::Int) :. All))
+--
+-- A fully specified index (with no `All`s) would return a single
+-- element (zero dimensional array).
slice :: (Slice slix, Elt e)
=> Acc (Array (FullShape slix) e)
-> Exp slix

0 comments on commit c58fc19

Please sign in to comment.