Make combine2 work with selectors
[packages/dph.git] / dph-prim-seq / Data / Array / Parallel / Unlifted / Sequential.hs
1 -----------------------------------------------------------------------------
2 -- |
3 -- Module : Data.Array.Parallel.Unlifted.Sequential
4 -- Copyright : (c) [2001..2002] Manuel M T Chakravarty & Gabriele Keller
5 -- (c) [2006..2007] Manuel M T Chakravarty & Roman Leshchinskiy
6 -- License : see libraries/ndp/LICENSE
7 --
8 -- Maintainer : Roman Leshchinskiy <rl@cse.unsw.edu.au>
9 -- Stability : experimental
10 -- Portability : portable
11 --
12 -- Description ---------------------------------------------------------------
13 --
14 -- External interface to unlifted arrays.
15 --
16 -- Todo ----------------------------------------------------------------------
17 --
18
19 module Data.Array.Parallel.Unlifted.Sequential (
20
21 -- * Array classes
22 UA,
23
24 -- * Array types
25 UArr, USegd, USel2,
26
27 -- * Basic operations
28 lengthU, nullU, emptyU, singletonU, consU, unitsU,
29 replicateU, (!:), (+:+),
30 interleaveU, indexedU, repeatU,
31
32 -- * Subarrays
33 sliceU, extractU,
34 tailU,
35 takeU, dropU, splitAtU,
36 {-takeWhileU, dropWhileU, spanU, breakU,-}
37
38 -- * Permutations
39 permuteU, mbpermuteU, bpermuteU, bpermuteDftU, reverseU, updateU,
40
41
42 -- * Higher-order operations
43 mapU, zipWithU, zipWith3U,
44 filterU, packU,
45 foldlU, foldl1U, foldl1MaybeU,
46 {-foldrU, foldr1U,-}
47 foldU, fold1U, fold1MaybeU,
48 scanlU, scanl1U,
49 {-scanrU, scanr1U,-}
50 scanU, scan1U,
51 scanResU,
52 mapAccumLU,
53
54 -- Segmented filter and combines
55 combineU, combine2U, combineSU,
56
57 -- * Searching
58 elemU, notElemU,
59 {-lookupU, indexOfU,-}
60
61 -- * Logical operations
62 andU, orU, anyU, allU,
63
64 -- * Arithmetic operations
65 sumU, productU,
66 maximumU, minimumU,
67 maximumByU, minimumByU,
68 maximumIndexU, minimumIndexU,
69 maximumIndexByU, minimumIndexByU,
70
71 -- * Arrays of pairs
72 zipU, zip3U, unzipU, unzip3U, fstU, sndU,
73 {-crossU,-}
74
75 -- * Enumerations
76 enumFromToU, enumFromThenToU, enumFromStepLenU, enumFromToEachU, enumFromStepLenEachU,
77
78 -- * Searching
79 findU, findIndexU,
80
81 -- * Selectors
82 lengthUSel2, tagsUSel2, indicesUSel2, elementsUSel2_0, elementsUSel2_1,
83 mkUSel2,
84
85 -- * Conversions to\/from lists
86 toU, fromU,
87
88 -- * Unlifted.Sequential arrays
89 randomU, randomRU,
90
91 -- * I\/O
92 UIO(..),
93
94 -- * Basic operations (segmented)
95 {-repeatCU,-} replicateSU, replicateRSU, appendSU, indicesSU, indicesSU',
96
97 -- * Higher-order operations (segmented)
98 foldlSU, foldSU, fold1SU, foldlRU,
99 {-scanSU, scan1SU,-}
100
101 -- * Higher-order operations (regular)
102 foldlRU,
103
104 -- * Logical operations (segmented)
105 andSU, orSU,
106
107 -- * Arithmetic operations (segmented)
108 sumSU, productSU, maximumSU, minimumSU,
109
110 -- * Arithmetic operations (regular segmented)
111 sumRU,
112
113 -- * Segment descriptors
114 lengthUSegd, lengthsUSegd, indicesUSegd, elementsUSegd, lengthsToUSegd, mkUSegd,
115
116 -- * Mutable arrays
117 MUArr, newU, newMU, copyMU, permuteMU, readMU, writeMU,
118 hasAtomicWriteMU, atomicUpdateMU, unsafeFreezeAllMU,
119
120 -- * Streams
121 streamU, unstreamU,
122
123 -- * Library id
124 idstr, name, versnum, date, version, copyright, disclaimer,
125
126 -- FIXME
127 lengthU'
128
129 ) where
130
131 import Data.Array.Parallel.Base ((:*:)(..))
132 import Data.Array.Parallel.Unlifted.Sequential.Flat
133 import Data.Array.Parallel.Unlifted.Sequential.Segmented
134
135 -- version number is major.minor.patchlvl; don't change the format of the
136 -- `versnum' line as it is `grep'ed for by a Makefile
137 --
138 idstr = "$Id: FIXME: Have the build-system produce an id$"
139 name = "Unlifted.Sequential Array Library"
140 versnum = "0.6.0"
141 date = "28 Apr 2006"
142 version = name ++ ", version " ++ versnum ++ ", " ++ date
143 copyright = "Copyright (c) [2001..2006] \
144 \M M T Chakravarty, G Keller & R Leshchinskiy"
145 disclaimer = "This software is distributed under the terms \
146 \of the BSD3 license. NO WARRANTY WHATSOEVER IS PROVIDED. \
147 \See the details in the documentation."
148
149
150 -- |Parallel array instances of standard classes
151 -- ---------------------------------------------
152
153 -- |
154 instance (Eq e, UA e) => Eq (UArr e) where
155 a1 == a2 = lengthU a1 == lengthU a2 && foldlU cmp True (zipU a1 a2)
156 where
157 cmp r (e1 :*: e2) = e1 == e2 && r
158