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>
12#include <ginkgo/core/base/utils_helper.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> {
296 typename MatrixPtrType,
typename StreamType,
297 std::enable_if_t<!std::is_same_v<
298 std::remove_cv_t<detail::pointee<MatrixPtrType>>,
LinOp>>* =
nullptr>
300 StreamType&& os, MatrixPtrType&&
matrix,
302 std::remove_cv_t<detail::pointee<MatrixPtrType>>>::default_layout)
304 using MatrixType = detail::pointee<MatrixPtrType>;
306 typename MatrixType::index_type>
336template <
typename MatrixPtrType,
typename StreamType>
339 using MatrixType = detail::pointee<MatrixPtrType>;
341 typename MatrixType::index_type>
Definition lin_op.hpp:117
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition array.hpp:166
This class is used for function parameters in the place of raw pointers.
Definition utils_helper.hpp:41
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: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_binary(StreamType &&os, MatrixPtrType &&matrix)
Writes a matrix into an output stream in binary format.
Definition mtx_io.hpp:337
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.
Definition mtx_io.hpp:97
@ coordinate
The matrix should be written as a sparse matrix in coordinate format.
Definition mtx_io.hpp:101
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:299
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