Skip to content

Commit 22e6c3e

Browse files
committed
ClDenseVector struct instead of inheritance
1 parent a6cf061 commit 22e6c3e

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/GraphBLAS-sharp.Backend/Objects/Vector.fs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,35 +84,35 @@ type DenseVector<'a> =
8484
|> String.concat ""
8585

8686
member this.ToDevice(context: ClContext) =
87-
context.CreateClArray this.Values :?> ClDenseVector<'a>
87+
{ ClDenseVector.Values = context.CreateClArray this.Values }
8888

8989
static member FromArray(array: 'a [], isZero: 'a -> bool) =
9090
{ Values =
9191
array
9292
|> Array.map (fun v -> if isZero v then None else Some v) }
9393

9494
and ClDenseVector<'a> =
95-
inherit ClArray<'a option>
95+
{ Values: ClArray<'a option> }
9696

97-
member this.Size = this.Length
97+
member this.Size = this.Values.Length
9898

9999
member this.ToHost(q: MailboxProcessor<_>) =
100-
let vector = Array.zeroCreate this.Length
100+
let vector = Array.zeroCreate this.Values.Length
101101

102102
let _ =
103-
q.PostAndReply(fun ch -> Msg.CreateToHostMsg(this, vector, ch))
103+
q.PostAndReply(fun ch -> Msg.CreateToHostMsg(this.Values, vector, ch))
104104

105-
{ Values = vector }
105+
{ DenseVector.Values = vector }
106106

107107
interface IDeviceMemObject with
108108
member this.Dispose(q) =
109-
q.Post(Msg.CreateFreeMsg<_>(this))
109+
q.Post(Msg.CreateFreeMsg<_>(this.Values))
110110
q.PostAndReply(Msg.MsgNotifyMe)
111111

112112
member this.Dispose(q) = (this :> IDeviceMemObject).Dispose(q)
113113

114114
static member FromArray(context: ClContext, array: 'a option []) =
115-
context.CreateClArray array :?> ClDenseVector<'a>
115+
{ Values = context.CreateClArray array }
116116

117117
type TuplesVector<'a> =
118118
{ Indices: int []

0 commit comments

Comments
 (0)