@@ -127,38 +127,38 @@ module Vector =
127127 ClVector.Dense
128128 <| toDense processor allocationMode vector
129129
130- let map2AtLeastOne ( clContext : ClContext ) ( opAdd : Expr < AtLeastOne < 'a , 'b > -> 'c option >) workGroupSize =
131- let addSparse =
132- SparseVector.map2AtLeastOne clContext opAdd workGroupSize
133-
130+ let map2 ( clContext : ClContext ) ( opAdd : Expr < 'a option -> 'b option -> 'c option >) workGroupSize =
134131 let addDense =
135- DenseVector.map2AtLeastOne clContext opAdd workGroupSize
132+ DenseVector.map2 clContext opAdd workGroupSize
133+
134+ let addSparse =
135+ SparseVector.map2 clContext opAdd workGroupSize
136136
137137 fun ( processor : MailboxProcessor < _ >) allocationMode ( leftVector : ClVector < 'a >) ( rightVector : ClVector < 'b >) ->
138138 match leftVector, rightVector with
139- | ClVector.Sparse left, ClVector.Sparse right ->
140- ClVector.Sparse
141- <| addSparse processor allocationMode left right
142139 | ClVector.Dense left, ClVector.Dense right ->
143140 ClVector.Dense
144141 <| addDense processor allocationMode left right
142+ | ClVector.Sparse left, ClVector.Sparse right ->
143+ ClVector.Sparse
144+ <| addSparse processor allocationMode left right
145145 | _ -> failwith " Vector formats are not matching."
146146
147- let map2 ( clContext : ClContext ) ( opAdd : Expr < 'a option -> 'b option -> 'c option >) workGroupSize =
148- let addDense =
149- DenseVector.map2 clContext opAdd workGroupSize
150-
147+ let map2AtLeastOne ( clContext : ClContext ) ( opAdd : Expr < AtLeastOne < 'a , 'b > -> 'c option >) workGroupSize =
151148 let addSparse =
152- SparseVector.map2 clContext opAdd workGroupSize
149+ SparseVector.map2AtLeastOne clContext opAdd workGroupSize
150+
151+ let addDense =
152+ DenseVector.map2AtLeastOne clContext opAdd workGroupSize
153153
154154 fun ( processor : MailboxProcessor < _ >) allocationMode ( leftVector : ClVector < 'a >) ( rightVector : ClVector < 'b >) ->
155155 match leftVector, rightVector with
156- | ClVector.Dense left, ClVector.Dense right ->
157- ClVector.Dense
158- <| addDense processor allocationMode left right
159156 | ClVector.Sparse left, ClVector.Sparse right ->
160157 ClVector.Sparse
161158 <| addSparse processor allocationMode left right
159+ | ClVector.Dense left, ClVector.Dense right ->
160+ ClVector.Dense
161+ <| addDense processor allocationMode left right
162162 | _ -> failwith " Vector formats are not matching."
163163
164164 let map2General < 'a , 'b , 'c when 'a : struct and 'b : struct and 'c : struct >
@@ -183,21 +183,22 @@ module Vector =
183183 <| denseEWise processor allocationMode left right
184184 | _ -> failwith " Vector formats are not matching."
185185
186- let fillSubVector < 'a , 'b when 'a : struct and 'b : struct > maskOp ( clContext : ClContext ) workGroupSize =
186+ let private assignByMaskGeneral < 'a , 'b when 'a : struct and 'b : struct > ( clContext : ClContext ) op workGroupSize =
187+
187188 let sparseFillVector =
188- SparseVector.fillSubVector clContext ( Convert.fillSubToOption maskOp ) workGroupSize
189+ SparseVector.assignByMask clContext op workGroupSize
189190
190191 let denseFillVector =
191- DenseVector.fillSubVector clContext ( Convert.fillSubToOption maskOp ) workGroupSize
192+ DenseVector.assignByMask clContext op workGroupSize
192193
193194 let toSparseVector =
194195 DenseVector.toSparse clContext workGroupSize
195196
196197 let toSparseMask =
197198 DenseVector.toSparse clContext workGroupSize
198199
199- fun ( processor : MailboxProcessor < _ >) allocationMode ( vector : ClVector < 'a >) ( maskVector : ClVector < 'b >) ( value : ClCell < 'a >) ->
200- match vector, maskVector with
200+ fun ( processor : MailboxProcessor < _ >) allocationMode ( vector : ClVector < 'a >) ( mask : ClVector < 'b >) ( value : ClCell < 'a >) ->
201+ match vector, mask with
201202 | ClVector.Sparse vector, ClVector.Sparse mask ->
202203 ClVector.Sparse
203204 <| sparseFillVector processor allocationMode vector mask value
@@ -217,48 +218,11 @@ module Vector =
217218 ClVector.Dense
218219 <| denseFillVector processor allocationMode vector mask value
219220
220- let fillSubVectorComplemented < 'a , 'b when 'a : struct and 'b : struct > maskOp ( clContext : ClContext ) workGroupSize =
221-
222- let denseFillVector =
223- DenseVector.fillSubVector clContext ( Convert.fillSubComplementedToOption maskOp) workGroupSize
224-
225- let vectorToDense =
226- SparseVector.toDense clContext workGroupSize
227-
228- let maskToDense =
229- SparseVector.toDense clContext workGroupSize
230-
231- fun ( processor : MailboxProcessor < _ >) allocationMode ( leftVector : ClVector < 'a >) ( maskVector : ClVector < 'b >) ( value : ClCell < 'a >) ->
232- match leftVector, maskVector with
233- | ClVector.Sparse vector, ClVector.Sparse mask ->
234- let denseVector =
235- vectorToDense processor allocationMode vector
236-
237- let denseMask =
238- maskToDense processor allocationMode mask
239-
240- ClVector.Dense
241- <| denseFillVector processor allocationMode denseVector denseMask value
242- | ClVector.Dense vector, ClVector.Sparse mask ->
243- let denseMask =
244- maskToDense processor allocationMode mask
245-
246- ClVector.Dense
247- <| denseFillVector processor allocationMode vector denseMask value
248- | ClVector.Sparse vector, ClVector.Dense mask ->
249- let denseVector =
250- vectorToDense processor allocationMode vector
251-
252- ClVector.Dense
253- <| denseFillVector processor allocationMode denseVector mask value
254- | ClVector.Dense vector, ClVector.Dense mask ->
255- ClVector.Dense
256- <| denseFillVector processor allocationMode vector mask value
257-
258- let standardFillSubVector < 'a , 'b when 'a : struct and 'b : struct > = fillSubVector< 'a, 'b> Mask.fillSubOp< 'a>
221+ let assignByMask < 'a , 'b when 'a : struct and 'b : struct > clContext op workGroupSize =
222+ assignByMaskGeneral< 'a, 'b> clContext ( Convert.assignToOption op) workGroupSize
259223
260- let standardFillSubVectorComplemented < 'a , 'b when 'a : struct and 'b : struct > =
261- fillSubVectorComplemented < 'a, 'b> Mask.fillSubOp < 'a >
224+ let assignByMaskComplemented < 'a , 'b when 'a : struct and 'b : struct > clContext op workGroupSize =
225+ assignByMaskGeneral < 'a, 'b> clContext ( Convert.assignComplementedToOption op ) workGroupSize
262226
263227 let reduce ( clContext : ClContext ) workGroupSize ( opAdd : Expr < 'a -> 'a -> 'a >) =
264228 let sparseReduce =
0 commit comments