File tree Expand file tree Collapse file tree
src/GraphBLAS-sharp/Objects Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,15 +93,12 @@ module Matrix =
9393
9494 member this.ToCSR =
9595 let rowPointers =
96- let nnzPerRow = Array.zeroCreate this.RowCount
97- let rowPointers = Array.zeroCreate this.RowCount
96+ let pointers = Array.zeroCreate this.RowCount
9897
99- Array.iter ( fun rowIndex -> nnzPerRow.[ rowIndex] <- nnzPerRow.[ rowIndex] + 1 ) this.Rows
98+ Array.countBy id this.Rows
99+ |> Array.iter ( fun ( index , count ) -> pointers.[ index] <- count)
100100
101- for i in 1 .. this.RowCount - 1 do
102- rowPointers.[ i] <- rowPointers.[ i - 1 ] + nnzPerRow.[ i - 1 ]
103-
104- rowPointers
101+ Array.scan (+) 0 pointers
105102
106103 { RowCount = this.RowCount
107104 ColumnCount = this.ColumnCount
@@ -128,7 +125,7 @@ module Matrix =
128125 |> List.mapi ( fun i x -> ( x, i))
129126 |> List.filter ( fun pair -> not <| isZero ( fst pair)))
130127 |> List.fold
131- ( fun ( colPtrs , valueInx ) col -> (( colPtrs .Head + col.Length) :: colPtrs ), valueInx @ col)
128+ ( fun ( colPointers , valueInx ) col -> (( colPointers .Head + col.Length) :: colPointers ), valueInx @ col)
132129 ([ 0 ], [])
133130
134131 { Values =
You can’t perform that action at this time.
0 commit comments