@@ -23,6 +23,8 @@ module ClMatrix =
2323 q.Post( Msg.CreateFreeMsg<_>( this.RowPointers))
2424 q.PostAndReply( Msg.MsgNotifyMe)
2525
26+ member this.NNZ = this.Values.Length
27+
2628 type COO < 'elem when 'elem: struct > =
2729 { Context: ClContext
2830 RowCount: int
@@ -38,6 +40,8 @@ module ClMatrix =
3840 q.Post( Msg.CreateFreeMsg<_>( this.Rows))
3941 q.PostAndReply( Msg.MsgNotifyMe)
4042
43+ member this.NNZ = this.Values.Length
44+
4145 type CSC < 'elem when 'elem: struct > =
4246 { Context: ClContext
4347 RowCount: int
@@ -53,6 +57,8 @@ module ClMatrix =
5357 q.Post( Msg.CreateFreeMsg<_>( this.ColumnPointers))
5458 q.PostAndReply( Msg.MsgNotifyMe)
5559
60+ member this.NNZ = this.Values.Length
61+
5662 type Tuple < 'elem when 'elem: struct > =
5763 { Context: ClContext
5864 RowIndices: ClArray < int >
@@ -66,6 +72,8 @@ module ClMatrix =
6672 q.Post( Msg.CreateFreeMsg<_>( this.Values))
6773 q.PostAndReply( Msg.MsgNotifyMe)
6874
75+ member this.NNZ = this.Values.Length
76+
6977[<RequireQualifiedAccess>]
7078type ClMatrix < 'a when 'a: struct > =
7179 | CSR of ClMatrix.CSR < 'a >
@@ -89,3 +97,9 @@ type ClMatrix<'a when 'a: struct> =
8997 | ClMatrix.CSR matrix -> ( matrix :> IDeviceMemObject) .Dispose q
9098 | ClMatrix.COO matrix -> ( matrix :> IDeviceMemObject) .Dispose q
9199 | ClMatrix.CSC matrix -> ( matrix :> IDeviceMemObject) .Dispose q
100+
101+ member this.NNZ =
102+ match this with
103+ | ClMatrix.CSR matrix -> matrix.NNZ
104+ | ClMatrix.COO matrix -> matrix.NNZ
105+ | ClMatrix.CSC matrix -> matrix.NNZ
0 commit comments