File tree Expand file tree Collapse file tree 1 file changed +39
-33
lines changed Expand file tree Collapse file tree 1 file changed +39
-33
lines changed Original file line number Diff line number Diff line change @@ -68,40 +68,46 @@ type MtxReader(pathToFile: string) =
6868 let sortedData =
6969 match this.Symmetry with
7070 | General ->
71- [ 0 .. nnz - 1 ]
72- |> List.map ( fun _ -> streamReader.ReadLine() .Split( ' ' ))
73- |> Array.ofList
74- |> Array.Parallel.map
75- ( fun line ->
76- let i = int line.[ 0 ]
77- let j = int line.[ 1 ]
78-
79- let v =
80- converter
81- <| if line.Length > 2 then line.[ 2 ] else " "
82-
83- struct ( pack i j, v))
84- |> Array.sortBy ( fun struct ( packedIndex , _ ) -> packedIndex)
71+ let result =
72+ [| 0 .. nnz - 1 |]
73+ |> Array.map
74+ ( fun _ ->
75+ let line = streamReader.ReadLine() .Split( ' ' )
76+
77+ let i = int line.[ 0 ]
78+ let j = int line.[ 1 ]
79+
80+ let v =
81+ converter
82+ <| if line.Length > 2 then line.[ 2 ] else " "
83+
84+ struct ( pack i j, v))
85+
86+ Array.sortInPlaceBy ( fun struct ( packedIndex , _ ) -> packedIndex) result
87+ result
8588 | Symmetric ->
86- [ 0 .. nnz - 1 ]
87- |> List.map ( fun _ -> streamReader.ReadLine() .Split( ' ' ))
88- |> Array.ofList
89- |> Array.Parallel.map
90- ( fun line ->
91- let i = int line.[ 0 ]
92- let j = int line.[ 1 ]
93-
94- let v =
95- converter
96- <| if line.Length > 2 then line.[ 2 ] else " "
97-
98- if i = j then
99- [| struct ( pack i j, v) |]
100- else
101- [| struct ( pack i j, v)
102- struct ( pack j i, v) |])
103- |> Array.concat
104- |> Array.sortBy ( fun struct ( packedIndex , _ ) -> packedIndex)
89+ let result =
90+ [| 0 .. nnz - 1 |]
91+ |> Array.map
92+ ( fun _ ->
93+ let line = streamReader.ReadLine() .Split( ' ' )
94+
95+ let i = int line.[ 0 ]
96+ let j = int line.[ 1 ]
97+
98+ let v =
99+ converter
100+ <| if line.Length > 2 then line.[ 2 ] else " "
101+
102+ if i = j then
103+ [| struct ( pack i j, v) |]
104+ else
105+ [| struct ( pack i j, v)
106+ struct ( pack j i, v) |])
107+ |> Array.concat
108+
109+ Array.sortInPlaceBy ( fun struct ( packedIndex , _ ) -> packedIndex) result
110+ result
105111 | _ ->
106112 failwith
107113 <| sprintf " This symmetry processing is not implemented: %A " this.Symmetry
You can’t perform that action at this time.
0 commit comments