Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 997 Bytes

README.CXSparse.md

File metadata and controls

36 lines (27 loc) · 997 Bytes

CXSparse Matrix Market

fast_matrix_market provides read/write methods for CXSparse cs_xx structs.

Usage

#include <fast_matrix_market/app/CXSparse.hpp>

Reading

cs_dl *A;

std::ifstream f("input.mtx");
fast_matrix_market::read_matrix_market_cxsparse(f, &A, cs_dl_spalloc);

Note the last argument. It is the cs_*_spalloc routine that matches the type of A. It must be specified explicitly because it is impractical to autodetect due to the way CXSparse implements multiple index and value types. All CXSparse types are supported, such as cs_dl, cs_ci, cs_cl, etc.

read_matrix_market_cxsparse creates a triplet version of the matrix structure. For CSC, follow up with CXSparse's cs_compress():

cs_dl *csc_A = cs_dl_compress(A);

Writing

cs_dl *A;

std::ofstream f("output.mtx", std::ios_base::binary);
fast_matrix_market::write_matrix_market_cxsparse(f, A);

The write method supports both triplet and compressed matrices.