24#ifndef MORPHEUS_MATRIXMARKET_HPP
25#define MORPHEUS_MATRIXMARKET_HPP
27#include <impl/Morpheus_MatrixMarket_Impl.hpp>
62template <
typename Container,
typename Stream>
65 Morpheus::is_coo_matrix_format_container_v<Container> ||
66 Morpheus::is_dynamic_matrix_format_container_v<Container> ||
67 Morpheus::is_dense_matrix_format_container_v<Container> ||
68 Morpheus::is_dense_vector_format_container_v<Container>,
69 "Container must be either a CooMatrix, DynamicMatrix, DenseMatrix "
70 "or DenseVector container");
71 static_assert(Morpheus::has_host_memory_space_v<Container>,
72 "Container must reside in HostSpace");
73 Morpheus::IO::Impl::read_matrix_market_stream(container, input);
91template <
typename Container>
93 const std::string& filename) {
95 Morpheus::is_coo_matrix_format_container_v<Container> ||
96 Morpheus::is_dynamic_matrix_format_container_v<Container> ||
97 Morpheus::is_dense_matrix_format_container_v<Container> ||
98 Morpheus::is_dense_vector_format_container_v<Container>,
99 "Container must be either a CooMatrix, DynamicMatrix, DenseMatrix "
100 "or DenseVector container");
101 static_assert(Morpheus::has_host_memory_space_v<Container>,
102 "Container must reside in HostSpace");
103 std::ifstream file(filename.c_str());
107 filename + std::string(
"\" for reading"));
111 std::stringstream file_string(std::stringstream::in | std::stringstream::out);
112 std::vector<char> buffer(
113 file.rdbuf()->pubseekoff(0, std::ios::end, std::ios::in));
114 file.rdbuf()->pubseekpos(0, std::ios::in);
115 file.rdbuf()->sgetn(&buffer[0], buffer.size());
116 file_string.write(&buffer[0], buffer.size());
150template <
typename Container,
typename Stream>
153 Morpheus::is_coo_matrix_format_container_v<Container> ||
154 Morpheus::is_dynamic_matrix_format_container_v<Container> ||
155 Morpheus::is_dense_matrix_format_container_v<Container> ||
156 Morpheus::is_dense_vector_format_container_v<Container>,
157 "Container must be either a CooMatrix, DynamicMatrix, DenseMatrix "
158 "or DenseVector container");
159 static_assert(Morpheus::has_host_memory_space_v<Container>,
160 "Container must reside in HostSpace");
161 Morpheus::IO::Impl::write_matrix_market_stream(container, output);
180template <
typename Container>
182 const std::string& filename) {
184 Morpheus::is_coo_matrix_format_container_v<Container> ||
185 Morpheus::is_dynamic_matrix_format_container_v<Container> ||
186 Morpheus::is_dense_matrix_format_container_v<Container> ||
187 Morpheus::is_dense_vector_format_container_v<Container>,
188 "Container must be either a CooMatrix, DynamicMatrix, DenseMatrix "
189 "or DenseVector container");
190 static_assert(Morpheus::has_host_memory_space_v<Container>,
191 "Container must reside in HostSpace");
192 std::ofstream file(filename.c_str());
196 filename + std::string(
"\" for writing"));
200 std::stringstream file_string(std::stringstream::in | std::stringstream::out);
204 file.rdbuf()->sputn(file_string.str().c_str(), file_string.str().size());
Definition: Morpheus_Exceptions.hpp:51
void read_matrix_market_file(Container &container, const std::string &filename)
Reads a MatrixMarket file from file.
Definition: Morpheus_MatrixMarket.hpp:92
void read_matrix_market_stream(Container &container, Stream &input)
Reads a MatrixMarket file from a stream.
Definition: Morpheus_MatrixMarket.hpp:63
void write_matrix_market_file(const Container &container, const std::string &filename)
Writes a container to a file in the MatrixMarket file format.
Definition: Morpheus_MatrixMarket.hpp:181
void write_matrix_market_stream(const Container &container, Stream &output)
Writes a container to a stream in the MatrixMarket file format.
Definition: Morpheus_MatrixMarket.hpp:151
Generic Morpheus interfaces.
Definition: dummy.cpp:24