You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/specs/stdlib_io.md
+133Lines changed: 133 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -321,3 +321,136 @@ Exceptions trigger an `error stop` unless the optional `err` argument is provide
321
321
{!example/io/example_get_file.f90!}
322
322
```
323
323
324
+
## Matrix Market Format I/O
325
+
326
+
### Status
327
+
328
+
Experimental
329
+
330
+
### Description
331
+
332
+
The Matrix Market I/O module provides support for reading and writing matrices in the Matrix Market format, a simple ASCII format for sparse and dense matrices developed at NIST. The format supports real, complex, and integer matrices with various symmetry properties.
333
+
334
+
### `load_mm` - load a matrix from Matrix Market file
335
+
336
+
Loads a 2D matrix from a Matrix Market format file. Symmetric matrices are expanded to full storage.
-`filename`: Shall be a character expression containing the Matrix Market file name to read from.
355
+
356
+
-`matrix`: Shall be an allocatable rank-2 array of type `real`, `complex`, or `integer` that will contain the loaded matrix.
357
+
358
+
-`iostat` (optional): Shall be a scalar of type `integer` that receives the error status. Zero indicates success.
359
+
360
+
-`iomsg` (optional): Shall be an allocatable character string that receives the error message if iostat is non-zero.
361
+
362
+
**`Coordinate` format**
363
+
364
+
`call `[[stdlib_io_mm(module):load_mm(interface)]]`(filename, index, data [, iostat, iomsg])`
365
+
366
+
-`filename`: Shall be a character expression containing the Matrix Market file name to read from.
367
+
368
+
-`index`: Shall be an allocatable rank-2 array of type `integer` that will contain the indices of the loaded matrix.
369
+
370
+
-`data`: Shall be an allocatable rank-1 array of type `real`, `complex`, or `integer` that will contain the values of the loaded matrix.
371
+
372
+
-`iostat` (optional): Shall be a scalar of type `integer` that receives the error status. Zero indicates success.
373
+
374
+
-`iomsg` (optional): Shall be an allocatable character string that receives the error message if iostat is non-zero.
375
+
376
+
### `save_mm` - save a matrix to Matrix Market file
377
+
378
+
Saves a 2D matrix to Matrix Market format file.
379
+
380
+
#### Syntax
381
+
382
+
- To save a matrix of `array` format:
383
+
384
+
`call `[[stdlib_io_mm(module):save_mm(interface)]]`(filename, matrix [, comment, format, symmetry, iostat, iomsg])`
385
+
386
+
- To save a matrix of `coordinate` format:
387
+
388
+
`call `[[stdlib_io_mm(module):save_mm(interface)]]`(filename, index, data [, comment, format, symmetry, iostat, iomsg])`
389
+
390
+
#### Arguments
391
+
392
+
**`Array` format**
393
+
394
+
`call `[[stdlib_io_mm(module):save_mm(interface)]]`(filename, matrix [, comment, format, symmetry, iostat, iomsg])`
395
+
396
+
-`filename`: Shall be a character expression containing the Matrix Market file name to write to.
397
+
398
+
-`matrix`: Shall be a rank-2 array of type `real`, `complex`, or `integer` to save.
399
+
400
+
-`comment` (optional): Shall be a character expression containing additional comments for the file header.
401
+
402
+
-`format` (optional): Shall be a character expression specifying how entries are written.
403
+
404
+
-`symmetry` (optional): Shall be a character expression defining the symmetry of the matrix. Allowed values: `auto`, `general`, `symmetric`, `skew-symmetric`, `hermitian`.
405
+
-`auto`: Detects the symmetry automatically, falls back to `general` if no symmetry is found.
406
+
-`general`: all entries are stored
407
+
-`symmetric` / `hermitian`: only the lower triangle (including diagonal) is stored
408
+
-`skew-symmetric`: only the strictly lower triangle (excluding diagonal) is stored
409
+
410
+
Default: `general`
411
+
412
+
-`iostat` (optional): Shall be a scalar of type `integer` that receives the error status. Zero indicates success.
413
+
414
+
-`iomsg` (optional): Shall be an allocatable character string that receives the error message if iostat is non-zero.
415
+
416
+
**`Coordinate` format**
417
+
418
+
`call `[[stdlib_io_mm(module):save_mm(interface)]]`(filename, index, data [, comment, format, symmetry, iostat, iomsg])`
419
+
420
+
-`filename`: Shall be a character expression containing the Matrix Market file name to write to.
421
+
422
+
-`index`: Shall be a rank-2 `integer` array of shape `(2, n)` specifying the indices of the entries.
423
+
- index(1,:) shall contain row indices
424
+
- index(2,:) shall contain column indices
425
+
426
+
-`data`: Shall be a rank-1 array of type `real`, `complex`, or `integer` to save.
427
+
- If `size(data) == n`, the values for each index are written.
428
+
- If `size(data) == 1`, a `pattern` matrix is written (no explicit values)
429
+
430
+
-`comment` (optional): Shall be a character expression containing additional comments for the file header.
431
+
432
+
-`format` (optional): Shall be a character expression specifying how entries are written.
433
+
434
+
-`symmetry` (optional): Shall be a character expression defining the symmetry of the matrix. Allowed values: `general`, `symmetric`, `skew-symmetric`, `hermitian`.
435
+
-`general`: all entries are stored
436
+
-`symmetric` / `hermitian`: only the lower triangle (including diagonal) is stored
437
+
-`skew-symmetric`: only the strictly lower triangle (excluding diagonal) is stored
438
+
439
+
-`iostat` (optional): Shall be a scalar of type `integer` that receives the error status. Zero indicates success.
440
+
441
+
-`iomsg` (optional): Shall be an allocatable character string that receives the error message if iostat is non-zero.
442
+
443
+
### Matrix Market Format Details
444
+
445
+
The Matrix Market format supports:
446
+
447
+
-**Object types**: Currently only `matrix` is supported
448
+
-**Formats**: `coordinate` (sparse) and `array` (dense)
0 commit comments