fast_matrix_market provides read and write methods for GraphBLAS GrB_Matrix and GrB_Vector objects.
Tested with SuiteSparse:GraphBLAS, but should work with any GraphBLAS implementation.
#include <fast_matrix_market/app/GraphBLAS.hpp>// Initialize GraphBLAS.
// GrB_init() has to be called before any other GraphBLAS methods else you get a GrB_PANIC.
GrB_init(GrB_NONBLOCKING); // or GrB_BLOCKINGGrB_Matrix A;
// or
GrB_Vector A;std::ifstream f("input.mtx");
fast_matrix_market::read_matrix_market_graphblas(f, &A);A's GrB_Type is determined by the first non-null condition:
- Explicit
desired_typeargument toread*().Awill be read as this type. %%GraphBLAS type <ctype>structured comment.- MatrixMarket header
field.
User types are not supported at this time. If you have a use case for user types stored in Matrix Market please get in touch.
Duplicate values are summed using GrB_PLUS_*.
Note: if A is a GrB_Vector then the Matrix Market file must be either a vector or a
1-by-N row or M-by-1 column matrix. Any other matrix will cause an exception to be thrown.
std::ofstream f("output.mtx", std::ios_base::binary);
fast_matrix_market::write_matrix_market_graphblas(f, A);Compatibility Note: GrB_Vector objects are written as vector Matrix Market files.
Many MatrixMarket loaders cannot read vector files. If this is a problem write the vector
as a 1-by-N or M-by-1 matrix.
The following GraphBLAS extensions are used. All are individually switchable. All are present in SuiteSparse:GraphBLAS.
GxB_FC32/GxB_FC64complex types. Standard GraphBLAS does not include complex number types.- Define
FMM_GXB_COMPLEX=0to disable.
- Define
GxB_Matrix_build_Scalaris used to build iso-valued matrices frompatternfiles.- Define
FMM_GXB_BUILD_SCALAR=0to disable.
- Define
GxB_Matrix_pack_FullCis used to efficiently readarrayfiles.- Define
FMM_GXB_PACK_UNPACK=0to disable
- Define
GxB_Iteratorfor zero-copy writes.- Define
FMM_GXB_ITERATORS=0to disable.
- Define
GxB_Matrix_type_nameto determine matrix type.- Define
FMM_GXB_TYPE_NAME=0to disable.
- Define
All extensions can be disabled by defining FMM_NO_GXB.