33 #ifndef GKO_CORE_BASE_MTX_IO_HPP_ 34 #define GKO_CORE_BASE_MTX_IO_HPP_ 40 #include <ginkgo/core/base/matrix_data.hpp> 60 template <
typename ValueType = default_precision,
typename IndexType =
int32>
61 matrix_data<ValueType, IndexType>
read_raw(std::istream &is);
93 template <
typename ValueType,
typename IndexType>
112 template <
typename MatrixType,
typename StreamType,
typename... MatrixArgs>
113 inline std::unique_ptr<MatrixType>
read(StreamType &&is, MatrixArgs &&... args)
115 auto mtx = MatrixType::create(std::forward<MatrixArgs>(args)...);
116 mtx->read(
read_raw<
typename MatrixType::value_type,
117 typename MatrixType::index_type>(is));
133 template <
typename MatrixType,
typename StreamType>
134 inline void write(StreamType &&os, MatrixType *matrix,
138 typename MatrixType::index_type>
148 #endif // GKO_CORE_BASE_MTX_IO_HPP_ The matrix should be written as dense matrix in column-major order.
void write(StreamType &&os, MatrixType *matrix, layout_type layout=layout_type::array)
Reads a matrix stored in matrix market format from an input stream.
Definition: mtx_io.hpp:134
layout_type
Specifies the layout type when writing data in matrix market format.
Definition: mtx_io.hpp:67
The Ginkgo namespace.
Definition: abstract_factory.hpp:45
The matrix should be written as a sparse matrix in coordinate format.
void write_raw(std::ostream &os, const matrix_data< ValueType, IndexType > &data, layout_type layout=layout_type::array)
Writes a matrix_data structure to a stream in matrix market format.
std::unique_ptr< MatrixType > read(StreamType &&is, MatrixArgs &&... args)
Reads a matrix stored in matrix market format from an input stream.
Definition: mtx_io.hpp:113
matrix_data< ValueType, IndexType > read_raw(std::istream &is)
Reads a matrix stored in matrix market format from an input stream.
This structure is used as an intermediate data type to store a sparse matrix.
Definition: matrix_data.hpp:102