@@ -18,7 +18,13 @@ module Vector =
1818 failwith " Not Implemented yet"
1919
2020 let ofList ( size : int ) ( elements : ( int * 'a ) list ) : GraphblasEvaluation < Vector < 'a >> =
21- failwith " Not Implemented yet"
21+ let ( indices , values ) =
22+ elements
23+ |> Array.ofList
24+ |> Array.sortBy fst
25+ |> Array.unzip
26+
27+ graphblas { return VectorCOO <| COOVector.FromTuples( size, indices, values) }
2228
2329 // можно оставить, но с условием, что будет создаваться full vector
2430 // let ofArray (array: 'a[]) : GraphblasEvaluation<Vector<'a>> =
@@ -31,7 +37,7 @@ module Vector =
3137 failwith " Not Implemented yet"
3238
3339 let zeroCreate < 'a when 'a : struct > ( size : int ) : GraphblasEvaluation < Vector < 'a >> =
34- failwith " Not Implemented yet "
40+ graphblas { return VectorCOO <| COOVector.FromTuples ( size , [||], [||]) }
3541
3642 (*
3743 methods
@@ -77,8 +83,9 @@ module Vector =
7783 match vector with
7884 | VectorCOO vector ->
7985 opencl {
80- let! resultIndices = Copy.copyArray vector.Indices
81- return Mask1D( resultIndices, vector.Size, true )
86+ let! indices = Copy.copyArray vector.Indices
87+ let! complementedMask = Mask.GetComplemented.mask1D <| Mask1D( indices, vector.Size, true )
88+ return complementedMask
8289 }
8390 |> EvalGB.fromCl
8491
@@ -106,9 +113,19 @@ module Vector =
106113 let extractValue ( vector : Vector < 'a >) ( idx : int ) : GraphblasEvaluation < Scalar < 'a >> =
107114 failwith " Not Implemented yet"
108115
116+ // assignToVector
109117 /// t <- vec
110118 let assignVector ( target : Vector < 'a >) ( source : Vector < 'a >) : GraphblasEvaluation < unit > =
111- failwith " Not Implemented yet"
119+ if target.Size <> source.Size then
120+ invalidArg " source" <| sprintf " The size of source vector must be %A . Received: %A " target.Size source.Size
121+
122+ match source, target with
123+ | VectorCOO source, VectorCOO target ->
124+ opencl {
125+ target.Indices <- source.Indices
126+ target.Values <- source.Values
127+ }
128+ |> EvalGB.fromCl
112129
113130 /// t.[ mask] <- vec
114131 let assignSubVector ( target : Vector < 'a >) ( mask : Mask1D ) ( source : Vector < 'a >) : GraphblasEvaluation < unit > =
0 commit comments