2 #ifndef _LILC_MATRIX_SAVE_H_ 3 #define _LILC_MATRIX_SAVE_H_ 5 inline void put_header(std::string& header,
bool sym =
false)
7 header=
"%%MatrixMarket matrix coordinate real ";
14 template <
class el_type>
17 std::ofstream out(filename.c_str(), std::ios::out | std::ios::binary);
21 out.flags(std::ios_base::scientific);
24 put_header(header, sym);
26 out << header << std::endl;
27 out << n_rows() <<
" " << n_cols() <<
" " << nnz() <<
"\n";
29 for(
int i = 0; i < n_cols(); i++) {
30 for(
unsigned int j = 0; j < m_idx[i].size(); j++) {
31 out << m_idx[i][j]+1 <<
" " << i+1 <<
" " << m_x[i][j] <<
"\n";
bool save(std::string filename, bool sym=false)
Saves a matrix in matrix market format.
Definition: lilc_matrix_save.h:15