33#ifndef GKO_PUBLIC_CORE_BASE_MTX_IO_HPP_
34#define GKO_PUBLIC_CORE_BASE_MTX_IO_HPP_
40#include <ginkgo/core/base/matrix_data.hpp>
60template <
typename ValueType = default_precision,
typename IndexType =
int32>
95template <
typename ValueType = default_precision,
typename IndexType =
int32>
114template <
typename ValueType = default_precision,
typename IndexType =
int32>
147template <
typename ValueType,
typename IndexType>
168template <
typename ValueType,
typename IndexType>
190 auto mtx = MatrixType::create(std::forward<MatrixArgs>(
args)...);
191 mtx->read(
read_raw<
typename MatrixType::value_type,
192 typename MatrixType::index_type>(
is));
215 auto mtx = MatrixType::create(std::forward<MatrixArgs>(
args)...);
217 typename MatrixType::index_type>(
is));
241 auto mtx = MatrixType::create(std::forward<MatrixArgs>(
args)...);
243 typename MatrixType::index_type>(
is));
251template <
typename ValueType>
279template <
typename MatrixType>
280struct mtx_io_traits {
285template <
typename ValueType>
286struct mtx_io_traits<
gko::matrix::Dense<ValueType>> {
292struct mtx_io_traits<
gko::matrix::Fft> {
298struct mtx_io_traits<
gko::matrix::Fft2> {
304struct mtx_io_traits<
gko::matrix::Fft3> {
323template <
typename MatrixPtrType,
typename StreamType>
327 std::remove_cv_t<detail::pointee<MatrixPtrType>>>::default_layout)
329 using MatrixType = detail::pointee<MatrixPtrType>;
331 typename MatrixType::index_type>
351template <
typename MatrixPtrType,
typename StreamType>
354 using MatrixType = detail::pointee<MatrixPtrType>;
356 typename MatrixType::index_type>
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
std::unique_ptr< MatrixType > read_binary(StreamType &&is, MatrixArgs &&... args)
Reads a matrix stored in binary format from an input stream.
Definition mtx_io.hpp:212
void write_binary_raw(std::ostream &os, const matrix_data< ValueType, IndexType > &data)
Writes a matrix_data structure to a stream in binary format.
std::unique_ptr< MatrixType > read_generic(StreamType &&is, MatrixArgs &&... args)
Reads a matrix stored either in binary or matrix market format from an input stream.
Definition mtx_io.hpp:238
matrix_data< ValueType, IndexType > read_binary_raw(std::istream &is)
Reads a matrix stored in Ginkgo's binary matrix format from an input stream.
matrix_data< ValueType, IndexType > read_generic_raw(std::istream &is)
Reads a matrix stored in either binary or matrix market format from an input stream.
void write(StreamType &&os, MatrixPtrType &&matrix, layout_type layout=detail::mtx_io_traits< std::remove_cv_t< detail::pointee< MatrixPtrType > > >::default_layout)
Writes a matrix into an output stream in matrix market format.
Definition mtx_io.hpp:324
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.
void write_binary(StreamType &&os, MatrixPtrType &&matrix)
Writes a matrix into an output stream in binary format.
Definition mtx_io.hpp:352
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:188
layout_type
Specifies the layout type when writing data in matrix market format.
Definition mtx_io.hpp:121
@ array
The matrix should be written as dense matrix in column-major order.
@ coordinate
The matrix should be written as a sparse matrix in coordinate format.
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:155