|
|
◆ mm_write()
| void mm_write |
( |
char * |
fname, |
|
|
char * |
matcode, |
|
|
int |
nrow, |
|
|
int |
ncol, |
|
|
int |
nnz, |
|
|
double |
val[], |
|
|
int |
lval, |
|
|
int |
ptr[], |
|
|
int |
lptr, |
|
|
int |
ind[], |
|
|
int |
lind, |
|
|
int |
base, |
|
|
int |
fchk, |
|
|
int |
format, |
|
|
int * |
info |
|
) |
| |
Write a matrix to the Matrix Market file
- Purpose
- This function writes a sparse (CSR, CSC or COO format) or dense matrix to the Matrix Market file.
The data is written as it is without checking the contents.
- Parameters
-
| [in] | fname | Input file name.
If fname = NULL, stdout is assumed. |
| [in] | matcode[] | Array matcode[4]
Matrix type code.
matcode[0]:
= 'M': matrix.
matcode[1]: Storage format.
= 'C': sparse matrix (CSC format).
= 'A': dense matrix (column major).
matcode[2]: Data type.
= 'R': real.
= 'I': integer.
= 'C': complex.
= 'P': pattern (Only rowind and colind are stored. Data (val) is not stored).
matcode[3]: Matrix shape.
= 'G': genaral matrix.
= 'S': symmetric matrix.
= 'Z': skew-symmetric matrix.
= 'H': Hermitian matrix. |
| [in] | nrow | Number of rows of the matrix. (nrow >= 0) (If nrow = 0, returns without computation) |
| [in] | ncol | Number of columns of the matrix. (ncol >= 0) (If ncol = 0, returns without computation) |
| [in] | nnz | Number of nonzero elements of the matrix. (nnz >= 0) (If nnz = 0, returns without computation) |
| [in] | val[] | Array val[lval]
Nonzero elements of sparse matrix, or, all elements of dense matrix.
If data type is integer, the value will be rounded when writing.
Not referenced if matcode[2] = 'P'. |
| [in] | lval | Length of array val[]. (lval is as follows)
storage format data type matrix shape 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)
|
| [in] | 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)) |
| [in] | 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] | base | Indexing of rowind[] and colind[].
= 0: Zero-based (C style) indexing: Starting index is 0.
= 1: One-based (Fortran style) indexing: Starting index is 1. |
| [in] | fchk | Specify whether to check if the specified file already exists.
= 0: Overwrites without checking.
= 1: Returns an error (info = 2) if the specified file already exists. |
| [in] | format | Sparse input matrix format.
= 0: CSR format.
= 1: CSC format.
= 2: COO format. |
| [out] | info | = 0: Successful exit.
< 0: The (-info)-th argument is invalid.
= 1: Failed to open file.
= 2: File already exists. |
|