|
|
◆ mm_read()
| void mm_read |
( |
char * |
fname, |
|
|
char * |
matcode, |
|
|
int * |
nrow, |
|
|
int * |
ncol, |
|
|
int * |
nnz, |
|
|
double |
val[], |
|
|
int |
lval, |
|
|
int |
ptr[], |
|
|
int |
lptr, |
|
|
int |
ind[], |
|
|
int |
lind, |
|
|
int |
skip, |
|
|
int |
base, |
|
|
int |
format, |
|
|
int |
sort, |
|
|
int * |
info |
|
) |
| |
Read a matrix from the Matrix Market file
- Purpose
- This function reads a sparse (CSR, CSC oe COO format) or dense matrix from the Matrix Market file.
- Parameters
-
| [in] | fname | Input file name.
If fname = NULL, stdin is assumed. |
| [out] | matcode[] | Array matcode[4]
Matrix type code.
matcode[0]:
= 'M': matrix.
matcode[1]: Storage format.
= 'C': sparse matrix (COO format).
= 'A': dense matrix (column major).
matcode[2]: Data type.
= 'R': real.
= 'I': integer.
= 'C': complex.
= 'P': pattern (Only ptr and ind are stored. Data (val) is not stored).
matcode[3]: Matrix shape.
= 'G': genaral matrix.
= 'S': symmetric matrix.
= 'Z': skew-symmetric matrix.
= 'H': Hermitian matrix. |
| [out] | nrow | Number of rows of the matrix. |
| [out] | ncol | Number of columns of the matrix. |
| [out] | nnz | Number of nonzero elements of the matrix (for sparse matrix only). |
| [out] | val[] | Array val[lval]
Nonzero elements of sparse matrix, or, all elements of dense matrix (Complex numbers are stored in the order of real and imaginary parts).
Not referenced if matcode[2] = 'P'. |
| [in] | lval | Length of array val[]. (lval is as follows)
storage type data type matrix type lval (min. value)
------------- ------------------ ------------ -----------------
sparse, real or integer: nnz
complex: 2*nnz
dense, real or integer, general: nrow*ncol
symmetric: ncol*(ncol + 1)/2
skew: ncol*(ncol - 1)/2
complex, general: 2*nrow*ncol
symmetric: ncol*(ncol + 1)
skew: ncol*(ncol - 1)
Hermitian: ncol*(ncol + 1)
|
| [out] | ptr[] | Array ptr[lptr]
Row pointers (if matrix is stored in CSR format), column pointers (if matrix is stored in CSC format) or row indices (if matrix is stored in COO format) of nonzero elements.
Not referenced if matcode[1] = 'A'. |
| [in] | lptr | Length of array ptr[]. (lptr >= ncol + 1 (if matrix is stored in CSC format), lptr >= nrow + 1 (if matrix is stored in CSR format) or lptr >= nnz (if matrix is stored in COO format)) |
| [out] | ind[] | Array ind[lind]
Row indices (if matrix is stored in CSC format) or column indices (if matrix is stored in CSR or COO format) of nonzero elements.
Not referenced if matcode[1] = 'A'. |
| [in] | lind | Length of array ind[]. (lind >= nnz) |
| [in] | skip | Specify whether to read only a part of data.
= 0: Read all data.
= 1: Read header and size only (matrix data not to be read). |
| [in] | base | Indexing of ptr[] and ind[].
= 0: Zero-based (C style) indexing: Starting index is 0.
= 1: One-based (Fortran style) indexing: Starting index is 1. |
| [in] | format | Sparse matrix format when stored.
= 0: CSR format.
= 1: CSC format.
= 2: COO format. |
| [in] | sort | Specify whether to sort elements of sparse matrix in ascending order of column number within each row (if CSR) or row number within each column (if CSC).
= 0: Do not sort elements.
= 1: Sort elements. |
| [out] | info | = 0: Successful exit.
= i < 0: The (-i)-th argument is invalid.
= 1: Failed to open file.
= 3: File read error.
= 4: Invalid type. |
|