@@ -112,22 +112,20 @@ module Vector =
112112
113113 /// t.[ mask] <- vec
114114 let assignSubVector ( target : Vector < 'a >) ( mask : Mask1D ) ( source : Vector < 'a >) : GraphblasEvaluation < unit > =
115- match source, target with
116- | VectorCOO s, VectorCOO t ->
117- if t.Size <> mask.Size then
118- invalidArg " mask" <| sprintf " The size of mask must be %A . Received: %A " t.Size mask.Size
119-
120- if t.Size <> s.Size then
121- invalidArg " source" <| sprintf " The size of source vector must be %A . Received: %A " t.Size s.Size
122-
123- if mask.IsComplemented then
124- failwith " Not Implemented yet"
125- else
126- opencl {
127- let! ( resultIndices , resultValues ) = COOVector.AssignSubVector.run t.Indices t.Values s.Indices s.Values mask.Indices
128- t.Indices <- resultIndices
129- t.Values <- resultValues
130- }
115+ if target.Size <> mask.Size then
116+ invalidArg " mask" <| sprintf " The size of mask must be %A . Received: %A " target.Size mask.Size
117+
118+ if target.Size <> source.Size then
119+ invalidArg " source" <| sprintf " The size of source vector must be %A . Received: %A " target.Size source.Size
120+
121+ match source, target, mask with
122+ | VectorCOO source, VectorCOO target, mask when not mask.IsComplemented ->
123+ opencl {
124+ let! ( resultIndices , resultValues ) = COOVector.AssignSubVector.run target.Indices target.Values source.Indices source.Values mask.Indices
125+ target.Indices <- resultIndices
126+ target.Values <- resultValues
127+ }
128+ | _ -> failwith " Not Implemented"
131129 |> EvalGB.fromCl
132130
133131 /// t.[ idx] <- value
@@ -140,16 +138,14 @@ module Vector =
140138
141139 /// vec.[ mask] <- value
142140 let fillSubVector ( vector : Vector < 'a >) ( mask : Mask1D ) ( value : Scalar < 'a >) : GraphblasEvaluation < unit > =
143- match vector, value with
144- | VectorCOO vector, ScalarWrapped scalar ->
145- if mask.IsComplemented then
146- failwith " Not Implemented yet"
147- else
148- opencl {
149- let! ( resultIndices , resultValues ) = COOVector.FillSubVector.run vector.Indices vector.Values mask.Indices scalar.Value
150- vector.Indices <- resultIndices
151- vector.Values <- resultValues
152- }
141+ match vector, value, mask with
142+ | VectorCOO vector, ScalarWrapped scalar, mask when not mask.IsComplemented ->
143+ opencl {
144+ let! ( resultIndices , resultValues ) = COOVector.FillSubVector.run vector.Indices vector.Values mask.Indices scalar.Value
145+ vector.Indices <- resultIndices
146+ vector.Values <- resultValues
147+ }
148+ | _ -> failwith " Not Implemented"
153149 |> EvalGB.fromCl
154150
155151 (*
@@ -162,14 +158,12 @@ module Vector =
162158 let select ( predicate : UnaryOp < 'a , bool >) ( vector : Vector < 'a >) : GraphblasEvaluation < Vector < 'a >> = failwith " Not Implemented yet"
163159
164160 let reduce ( monoid : IMonoid < 'a >) ( vector : Vector < 'a >) : GraphblasEvaluation < Scalar < 'a >> =
161+ let ( ClosedBinaryOp plus ) = monoid.Plus
162+
165163 match vector with
166164 | VectorCOO vector ->
167165 opencl {
168- let! result = opencl {
169- let ( ClosedBinaryOp plus ) = monoid.Plus
170- return ! Sum.run vector.Values plus monoid.Zero
171- }
172-
166+ let! result = Sum.run vector.Values plus monoid.Zero
173167 return ScalarWrapped { Value = result }
174168 }
175169 |> EvalGB.fromCl
0 commit comments