fast_matrix_market
provides read/write methods for Armadillo sparse and dense matrices.
#include <fast_matrix_market/app/Armadillo.hpp>
arma::Mat<double> A;
// or
arma::SpMat<double> A;
Not restricted to double
matrices. Any type supported by Armadillo that makes sense in Matrix Market is also supported, such as int64_t
, float
, std::complex<double>
, etc.
std::ifstream f("input.mtx");
fast_matrix_market::read_matrix_market_arma(f, A);
Note: Armadillo versions older than 10.5 did not zero-initialize memory.
On those versions reading any Matrix Market file into a dense arma::Mat
is not supported.
std::ofstream f("output.mtx", std::ios_base::binary);
fast_matrix_market::write_matrix_market_arma(f, A);