Class MatrixMarketWriter
A utility class for writing matrices (from the Flag4j library) to a file in the Matrix Market Exchange Format.
This class supports writing both dense and sparse matrices (real, complex, or pattern) to the Matrix Market format. Dense matrices are written in the array (dense) format, while sparse (both COO and CSR) matrices are written in the coordinate (COO) format.
If the matrix is symmetric/Hermitian it will be detected during the write and the appropriate header will be formed.
Currently Supported Matrix Types:
- Matrix(real dense)
- CMatrix(complex dense)
- CooMatrix(real sparse COO)
- CsrMatrix(real sparse CSR, converted to COO)
- CooCMatrix(complex sparse COO)
- CsrCMatrix(complex sparse CSR, converted to COO)
Attempting to write a matrix type not listed above will result in an
 IllegalArgumentException.
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidwrite(String filePath, MatrixMixin<?, ?, ?, ?> mat, boolean isPattern, String... comments) Writes a matrix to a file in Matrix Market Exchange Format file.static voidwrite(String filePath, MatrixMixin<?, ?, ?, ?> mat, String... comments) Writes a matrix to a file in Matrix Market Exchange Format file.
- 
Method Details- 
writepublic static void write(String filePath, MatrixMixin<?, ?, throws IOException?, ?> mat, String... comments) Writes a matrix to a file in Matrix Market Exchange Format file. If matis a CSR matrix, it will be converted to a COO matrix and saved as a coordinate matrix.Currently supported matrix types: - Matrix(real dense)
- CMatrix(complex dense)
- CooMatrix(real sparse COO)
- CsrMatrix(real sparse CSR, converted to COO)
- CooCMatrix(complex sparse COO)
- CsrCMatrix(complex sparse CSR, converted to COO)
 To specify that a matrix should be written as a pattern matrix use write(String, MatrixMixin, boolean, String...).- Parameters:
- filePath- Path of the file to write to.
- mat- Matrix to write to file.
- comments- Comments to prepend to file. Each comment will be written to its own line. May be- null; in this case the parameter will be ignored.
- Throws:
- IOException- If an I/O error occurs.
- IllegalArgumentException- If- matis not a supported matrix type for writing to a Matrix Market Exchange Format file.
- See Also:
 
- 
writepublic static void write(String filePath, MatrixMixin<?, ?, throws IOException?, ?> mat, boolean isPattern, String... comments) Writes a matrix to a file in Matrix Market Exchange Format file. If matis a CSR matrix, it will be converted to a COO matrix and saved as a coordinate matrix.Currently supported matrix types: - Matrix(real dense)
- CMatrix(complex dense)
- CooMatrix(real sparse COO)
- CsrMatrix(real sparse CSR, converted to COO)
- CooCMatrix(complex sparse COO)
- CsrCMatrix(complex sparse CSR, converted to COO)
 - Parameters:
- filePath- Path of the file to write to.
- mat- Matrix to write to file.
- isPattern- Flag indicating if- matshould be written as a pattern matrix (- true) or not (- false).
- comments- Comments to prepend to file. Each comment will be written to its own line. May be- null; in this case the parameter will be ignored.
- Throws:
- IOException- If an I/O error occurs.
- IllegalArgumentException- If- matis not a supported matrix type for writing to a Matrix Market Exchange Format file.
- See Also:
 
 
-