22
33open Brahma.FSharp
44open GraphBLAS.FSharp .Backend
5+ open GraphBLAS.FSharp .Backend .ArraysExtensions
56
67type VectorFormat =
78 | COO
@@ -72,48 +73,6 @@ and ClCooVector<'a> =
7273
7374 member this.Dispose ( q ) = ( this :> IDeviceMemObject) .Dispose( q)
7475
75- type DenseVector < 'a > =
76- { Values: 'a option [] }
77-
78- member this.Size = this.Values.Length
79-
80- override this.ToString () =
81- [ sprintf " Dense Vector\n "
82- sprintf " Size: %i \n " this.Values.Length
83- sprintf " Values: %A \n " this.Values ]
84- |> String.concat " "
85-
86- member this.ToDevice ( context : ClContext ) =
87- { ClDenseVector.Values = context.CreateClArray this.Values }
88-
89- static member FromArray ( array : 'a [], isZero : 'a -> bool ) =
90- { Values =
91- array
92- |> Array.map ( fun v -> if isZero v then None else Some v) }
93-
94- and ClDenseVector < 'a > =
95- { Values: ClArray < 'a option > }
96-
97- member this.Size = this.Values.Length
98-
99- member this.ToHost ( q : MailboxProcessor < _ >) =
100- let vector = Array.zeroCreate this.Values.Length
101-
102- let _ =
103- q.PostAndReply( fun ch -> Msg.CreateToHostMsg( this.Values, vector, ch))
104-
105- { DenseVector.Values = vector }
106-
107- interface IDeviceMemObject with
108- member this.Dispose ( q ) =
109- q.Post( Msg.CreateFreeMsg<_>( this.Values))
110- q.PostAndReply( Msg.MsgNotifyMe)
111-
112- member this.Dispose ( q ) = ( this :> IDeviceMemObject) .Dispose( q)
113-
114- static member FromArray ( context : ClContext , array : 'a option []) =
115- { Values = context.CreateClArray array }
116-
11776type TuplesVector < 'a > =
11877 { Indices: int []
11978 Values: 'a []
@@ -169,7 +128,7 @@ and ClTuplesVector<'a> =
169128
170129type Vector < 'a when 'a: struct > =
171130 | VectorCOO of COOVector < 'a >
172- | VectorDense of DenseVector < 'a >
131+ | VectorDense of 'a option []
173132 member this.Size =
174133 match this with
175134 | VectorCOO vector -> vector.Size
@@ -182,7 +141,7 @@ type Vector<'a when 'a: struct> =
182141
183142and ClVector < 'a when 'a : struct > =
184143 | ClVectorCOO of ClCooVector < 'a >
185- | ClVectorDense of ClDenseVector < 'a >
144+ | ClVectorDense of ClArray < 'a option >
186145 member this.Size =
187146 match this with
188147 | ClVectorCOO vector -> vector.Size
0 commit comments