@@ -45,9 +45,7 @@ module Matrix =
4545 Values = copyData processor allocationMode m.Values }
4646 | ClMatrix.Rows matrix ->
4747 matrix.Rows
48- |> Array.map ( function
49- Some vector -> Some <| vectorCopy processor allocationMode vector
50- | None -> None)
48+ |> Array.map ( Option.bind <| ( Some << ( vectorCopy processor allocationMode)))
5149 |> fun rows ->
5250 { Context = clContext
5351 RowCount = matrix.RowCount
@@ -69,6 +67,8 @@ module Matrix =
6967 let transpose =
7068 CSR.Matrix.transpose clContext workGroupSize
7169
70+ let rowsToCSR = Rows.Matrix.toCSR clContext workGroupSize
71+
7272 fun ( processor : MailboxProcessor < _ >) allocationMode ( matrix : ClMatrix < 'a >) ->
7373 match matrix with
7474 | ClMatrix.COO m -> toCSR processor allocationMode m |> ClMatrix.CSR
@@ -77,30 +77,36 @@ module Matrix =
7777 m.ToCSR
7878 |> transpose processor allocationMode
7979 |> ClMatrix.CSR
80+ | ClMatrix.Rows m ->
81+ rowsToCSR processor allocationMode m
82+ |> ClMatrix.CSR
8083
8184 /// <summary>
8285 /// Returns the matrix, represented in CSR format, that is equal to the given one.
8386 /// The given matrix should neither be used afterwards nor be disposed.
8487 /// </summary>
8588 ///<param name="clContext">OpenCL context.</param>
8689 ///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
87- let toCSRInplace ( clContext : ClContext ) workGroupSize =
88- let toCSRInplace =
90+ let toCSRInPlace ( clContext : ClContext ) workGroupSize =
91+ let toCSRInPlace =
8992 COO.Matrix.toCSRInplace clContext workGroupSize
9093
91- let transposeInplace =
94+ let transposeInPlace =
9295 CSR.Matrix.transposeInplace clContext workGroupSize
9396
97+ let rowsToCSR = Rows.Matrix.toCSR clContext workGroupSize
98+
9499 fun ( processor : MailboxProcessor < _ >) allocationMode ( matrix : ClMatrix < 'a >) ->
95100 match matrix with
96101 | ClMatrix.COO m ->
97- toCSRInplace processor allocationMode m
102+ toCSRInPlace processor allocationMode m
98103 |> ClMatrix.CSR
99104 | ClMatrix.CSR _ -> matrix
100105 | ClMatrix.CSC m ->
101106 m.ToCSR
102- |> transposeInplace processor allocationMode
107+ |> transposeInPlace processor allocationMode
103108 |> ClMatrix.CSR
109+ | _ -> failwith " not yet supported"
104110
105111 /// <summary>
106112 /// Creates a new matrix, represented in COO format, that is equal to the given one.
@@ -115,6 +121,9 @@ module Matrix =
115121 let transposeInplace =
116122 COO.Matrix.transposeInplace clContext workGroupSize
117123
124+ let rowsToCOO =
125+ Rows.Matrix.toCOO clContext workGroupSize
126+
118127 fun ( processor : MailboxProcessor < _ >) allocationMode ( matrix : ClMatrix < 'a >) ->
119128 match matrix with
120129 | ClMatrix.COO _ -> copy processor allocationMode matrix
@@ -124,39 +133,46 @@ module Matrix =
124133 |> toCOO processor allocationMode
125134 |> transposeInplace processor
126135 |> ClMatrix.COO
136+ | ClMatrix.Rows m ->
137+ rowsToCOO processor allocationMode m
138+ |> ClMatrix.COO
127139
128140 /// <summary>
129141 /// Returns the matrix, represented in COO format, that is equal to the given one.
130142 /// The given matrix should neither be used afterwards nor be disposed.
131143 /// </summary>
132144 ///<param name="clContext">OpenCL context.</param>
133145 ///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
134- let toCOOInplace ( clContext : ClContext ) workGroupSize =
135- let toCOOInplace =
146+ let toCOOInPlace ( clContext : ClContext ) workGroupSize =
147+ let toCOOInPlace =
136148 CSR.Matrix.toCOOInplace clContext workGroupSize
137149
138- let transposeInplace =
150+ let transposeInPlace =
139151 COO.Matrix.transposeInplace clContext workGroupSize
140152
153+ let rowsToCOO =
154+ Rows.Matrix.toCOO clContext workGroupSize
155+
141156 fun ( processor : MailboxProcessor < _ >) allocationMode ( matrix : ClMatrix < 'a >) ->
142157 match matrix with
143158 | ClMatrix.COO _ -> matrix
144159 | ClMatrix.CSR m ->
145- toCOOInplace processor allocationMode m
160+ toCOOInPlace processor allocationMode m
146161 |> ClMatrix.COO
147162 | ClMatrix.CSC m ->
148163 m.ToCSR
149- |> toCOOInplace processor allocationMode
150- |> transposeInplace processor
164+ |> toCOOInPlace processor allocationMode
165+ |> transposeInPlace processor
151166 |> ClMatrix.COO
167+ | _ -> failwith " not yet supported"
152168
153169 /// <summary>
154170 /// Creates a new matrix, represented in CSC format, that is equal to the given one.
155171 /// </summary>
156172 ///<param name="clContext">OpenCL context.</param>
157173 ///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
158174 let toCSC ( clContext : ClContext ) workGroupSize =
159- let toCSR = COO.Matrix.toCSR clContext workGroupSize
175+ let COOtoCSR = COO.Matrix.toCSR clContext workGroupSize
160176
161177 let copy = copy clContext workGroupSize
162178
@@ -174,9 +190,10 @@ module Matrix =
174190 |> ClMatrix.CSC
175191 | ClMatrix.COO m ->
176192 ( transposeCOO processor allocationMode m
177- |> toCSR processor allocationMode)
193+ |> COOtoCSR processor allocationMode)
178194 .ToCSC
179195 |> ClMatrix.CSC
196+ | _ -> failwith " not yet supported"
180197
181198 /// <summary>
182199 /// Returns the matrix, represented in CSC format, that is equal to the given one.
@@ -206,6 +223,7 @@ module Matrix =
206223 |> toCSRInplace processor allocationMode)
207224 .ToCSC
208225 |> ClMatrix.CSC
226+ | _ -> failwith " not yet supported"
209227
210228 let map ( clContext : ClContext ) ( opAdd : Expr < 'a option -> 'b option >) workGroupSize =
211229 let mapCOO =
@@ -271,7 +289,7 @@ module Matrix =
271289 let CSRElementwise =
272290 CSR.Matrix.map2AtLeastOneToCOO clContext opAdd workGroupSize
273291
274- let transposeCOOInplace =
292+ let transposeCOOInPlace =
275293 COO.Matrix.transposeInplace clContext workGroupSize
276294
277295 fun ( processor : MailboxProcessor < _ >) allocationMode matrix1 matrix2 ->
@@ -284,7 +302,7 @@ module Matrix =
284302 |> ClMatrix.COO
285303 | ClMatrix.CSC m1, ClMatrix.CSC m2 ->
286304 CSRElementwise processor allocationMode m1.ToCSR m2.ToCSR
287- |> transposeCOOInplace processor
305+ |> transposeCOOInPlace processor
288306 |> ClMatrix.COO
289307 | _ -> failwith " Matrix formats are not matching"
290308
@@ -301,15 +319,16 @@ module Matrix =
301319 /// </remarks>
302320 ///<param name="clContext">OpenCL context.</param>
303321 ///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
304- let transposeInplace ( clContext : ClContext ) workGroupSize =
305- let COOtransposeInplace =
322+ let transposeInPlace ( clContext : ClContext ) workGroupSize =
323+ let COOTransposeInPlace =
306324 COO.Matrix.transposeInplace clContext workGroupSize
307325
308326 fun ( processor : MailboxProcessor < _ >) matrix ->
309327 match matrix with
310- | ClMatrix.COO m -> COOtransposeInplace processor m |> ClMatrix.COO
328+ | ClMatrix.COO m -> COOTransposeInPlace processor m |> ClMatrix.COO
311329 | ClMatrix.CSR m -> ClMatrix.CSC m.ToCSC
312330 | ClMatrix.CSC m -> ClMatrix.CSR m.ToCSR
331+ | ClMatrix.Rows _ -> failwith " not yet supported"
313332
314333 /// <summary>
315334 /// Transposes the given matrix and returns result as a new matrix.
@@ -352,6 +371,7 @@ module Matrix =
352371 Columns = copy processor allocationMode m.Rows
353372 Values = copyData processor allocationMode m.Values }
354373 |> ClMatrix.CSR
374+ | ClMatrix.Rows _ -> failwith " not yet supported"
355375
356376 let mxm
357377 ( opAdd : Expr < 'c -> 'c -> 'c option >)
0 commit comments