@@ -45,7 +45,7 @@ type MtxReader(pathToFile: string) =
4545 Nnz = nnz
4646 |}
4747
48- member this.ReadMatrixReal () : Matrix < float32 > =
48+ member this.ReadMatrixReal ( converter : string -> 'a ) : Matrix < 'a > =
4949 if object <> MtxMatrix then failwith " Object is not matrix"
5050 if field <> Real then failwith " Field is not real"
5151
@@ -73,7 +73,7 @@ type MtxReader(pathToFile: string) =
7373 ( fun line ->
7474 let i = int line.[ 0 ]
7575 let j = int line.[ 1 ]
76- let v = float32 line.[ 2 ]
76+ let v = converter line.[ 2 ]
7777 struct ( pack i j, v)
7878 )
7979 |> Array.sortBy ( fun struct ( packedIndex , _ ) -> packedIndex)
@@ -102,9 +102,9 @@ type MtxReader(pathToFile: string) =
102102 | Coordinate -> matrixFromCoordinateFormat ()
103103 | Array -> failwith " Unsupported matrix format"
104104
105- member this.ReadMatrixBoolean ( converter : string -> bool ) : Matrix < bool > =
105+ member this.ReadMatrixBoolean ( converter : string -> 'a ) : Matrix < 'a > =
106106 if object <> MtxMatrix then failwith " Object is not matrix"
107- // if field <> f then failwith "Field is not mmm "
107+ if field <> Pattern then failwith " Field is not boolean "
108108
109109 use streamReader = new StreamReader( pathToFile)
110110 while streamReader.Peek() = int '%' do
@@ -130,7 +130,7 @@ type MtxReader(pathToFile: string) =
130130 ( fun line ->
131131 let i = int line.[ 0 ]
132132 let j = int line.[ 1 ]
133- let v = converter line .[ 2 ]
133+ let v = converter " "
134134 struct ( pack i j, v)
135135 )
136136 |> Array.sortBy ( fun struct ( packedIndex , _ ) -> packedIndex)
@@ -159,6 +159,12 @@ type MtxReader(pathToFile: string) =
159159 | Coordinate -> matrixFromCoordinateFormat ()
160160 | Array -> failwith " Unsupported matrix format"
161161
162+ member this.ReadMatrix ( converter : string -> 'a ) : Matrix < 'a > =
163+ match field with
164+ | Real -> this.ReadMatrixReal( converter)
165+ | Pattern -> this.ReadMatrixBoolean( converter)
166+ | _ -> failwith " Not implemented"
167+
162168and MtxObject =
163169 | MtxMatrix
164170 | MtxVector
0 commit comments