5#ifndef GKO_PUBLIC_CORE_BASE_MTX_IO_HPP_
6#define GKO_PUBLIC_CORE_BASE_MTX_IO_HPP_
12#include <ginkgo/core/base/matrix_data.hpp>
32template <
typename ValueType = default_precision,
typename IndexType =
int32>
67template <
typename ValueType = default_precision,
typename IndexType =
int32>
86template <
typename ValueType = default_precision,
typename IndexType =
int32>
119template <
typename ValueType,
typename IndexType>
140template <
typename ValueType,
typename IndexType>
159template <
typename MatrixType,
typename StreamType,
typename... MatrixArgs>
160inline std::unique_ptr<MatrixType>
read(StreamType&& is, MatrixArgs&&... args)
162 auto mtx = MatrixType::create(std::forward<MatrixArgs>(args)...);
163 mtx->read(
read_raw<
typename MatrixType::value_type,
164 typename MatrixType::index_type>(is));
183template <
typename MatrixType,
typename StreamType,
typename... MatrixArgs>
185 MatrixArgs&&... args)
187 auto mtx = MatrixType::create(std::forward<MatrixArgs>(args)...);
189 typename MatrixType::index_type>(is));
209template <
typename MatrixType,
typename StreamType,
typename... MatrixArgs>
211 MatrixArgs&&... args)
213 auto mtx = MatrixType::create(std::forward<MatrixArgs>(args)...);
215 typename MatrixType::index_type>(is));
223template <
typename ValueType>
251template <
typename MatrixType>
252struct mtx_io_traits {
257template <
typename ValueType>
258struct mtx_io_traits<
gko::matrix::Dense<ValueType>> {
264struct mtx_io_traits<
gko::matrix::Fft> {
270struct mtx_io_traits<
gko::matrix::Fft2> {
276struct mtx_io_traits<
gko::matrix::Fft3> {
295template <
typename MatrixPtrType,
typename StreamType>
297 StreamType&& os, MatrixPtrType&& matrix,
299 std::remove_cv_t<detail::pointee<MatrixPtrType>>>::default_layout)
301 using MatrixType = detail::pointee<MatrixPtrType>;
303 typename MatrixType::index_type>
323template <
typename MatrixPtrType,
typename StreamType>
326 using MatrixType = detail::pointee<MatrixPtrType>;
328 typename MatrixType::index_type>
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:184
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:210
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:296
void write_binary(StreamType &&os, MatrixPtrType &&matrix)
Writes a matrix into an output stream in binary format.
Definition mtx_io.hpp:324
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:160
layout_type
Specifies the layout type when writing data in matrix market format.
Definition mtx_io.hpp:93
@ 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:127