5#ifndef GKO_PUBLIC_CORE_BASE_MTX_IO_HPP_
6#define GKO_PUBLIC_CORE_BASE_MTX_IO_HPP_
11#include <ginkgo/core/base/matrix_data.hpp>
31template <
typename ValueType = default_precision,
typename IndexType =
int32>
66template <
typename ValueType = default_precision,
typename IndexType =
int32>
85template <
typename ValueType = default_precision,
typename IndexType =
int32>
118template <
typename ValueType,
typename IndexType>
139template <
typename ValueType,
typename IndexType>
158template <
typename MatrixType,
typename StreamType,
typename... MatrixArgs>
159inline std::unique_ptr<MatrixType>
read(StreamType&& is, MatrixArgs&&... args)
161 auto mtx = MatrixType::create(std::forward<MatrixArgs>(args)...);
162 mtx->read(
read_raw<
typename MatrixType::value_type,
163 typename MatrixType::index_type>(is));
182template <
typename MatrixType,
typename StreamType,
typename... MatrixArgs>
184 MatrixArgs&&... args)
186 auto mtx = MatrixType::create(std::forward<MatrixArgs>(args)...);
188 typename MatrixType::index_type>(is));
208template <
typename MatrixType,
typename StreamType,
typename... MatrixArgs>
210 MatrixArgs&&... args)
212 auto mtx = MatrixType::create(std::forward<MatrixArgs>(args)...);
214 typename MatrixType::index_type>(is));
222template <
typename ValueType>
250template <
typename MatrixType>
251struct mtx_io_traits {
256template <
typename ValueType>
257struct mtx_io_traits<gko::matrix::Dense<ValueType>> {
263struct mtx_io_traits<gko::matrix::Fft> {
269struct mtx_io_traits<gko::matrix::Fft2> {
275struct mtx_io_traits<gko::matrix::Fft3> {
294template <
typename MatrixPtrType,
typename StreamType>
296 StreamType&& os, MatrixPtrType&&
matrix,
298 std::remove_cv_t<detail::pointee<MatrixPtrType>>>::default_layout)
300 using MatrixType = detail::pointee<MatrixPtrType>;
302 typename MatrixType::index_type>
322template <
typename MatrixPtrType,
typename StreamType>
325 using MatrixType = detail::pointee<MatrixPtrType>;
327 typename MatrixType::index_type>
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition array.hpp:166
The matrix namespace.
Definition dense_cache.hpp:24
The Ginkgo namespace.
Definition abstract_factory.hpp:20
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:183
void write_raw(std::ostream &os, const matrix_data< ValueType, IndexType > &data, layout_type layout=layout_type::coordinate)
Writes a matrix_data structure to a stream in matrix market format.
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:209
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:295
void write_binary(StreamType &&os, MatrixPtrType &&matrix)
Writes a matrix into an output stream in binary format.
Definition mtx_io.hpp:323
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:159
layout_type
Specifies the layout type when writing data in matrix market format.
Definition mtx_io.hpp:92
@ array
The matrix should be written as dense matrix in column-major order.
Definition mtx_io.hpp:96
@ coordinate
The matrix should be written as a sparse matrix in coordinate format.
Definition mtx_io.hpp:100
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:126