42#ifndef __Teuchos_MatrixMarket_Raw_Writer_hpp
43#define __Teuchos_MatrixMarket_Raw_Writer_hpp
45#include <Teuchos_SetScientific.hpp>
46#include "Teuchos_ArrayView.hpp"
66 template<
class ScalarType,
class OrdinalType>
98 std::ofstream out (
filename.c_str ());
100 "Failed to open file \"" <<
filename <<
"\" for writing.");
148 std::string dataType;
149 if (STS::isComplex) {
150 dataType =
"complex";
151 }
else if (STS::isOrdinal) {
152 dataType =
"integer";
159 out <<
"%%MatrixMarket matrix coordinate " << dataType <<
" general"
173 out << numRows <<
" " << numCols <<
" " <<
rowptr[numRows] <<
endl;
175 for (size_type
i = 0;
i < numRows; ++
i) {
181 out << (
i+1) <<
" " << (
j+1) <<
" ";
182 if (STS::isComplex) {
183 out << STS::real (
A_ij) <<
" " << STS::imag (
A_ij);
Templated Parameter List class.
Write a sparse matrix from raw CSR (compressed sparse row) storage to a Matrix Market file.
void write(std::ostream &out, const ArrayView< const OrdinalType > &rowptr, const ArrayView< const OrdinalType > &colind, const ArrayView< const ScalarType > &values, const OrdinalType numRows, const OrdinalType numCols)
Write the sparse matrix to the given output stream.
void writeFile(const std::string &filename, const ArrayView< const OrdinalType > &rowptr, const ArrayView< const OrdinalType > &colind, const ArrayView< const ScalarType > &values, const OrdinalType numRows, const OrdinalType numCols)
Write the sparse matrix to the given file.
Smart reference counting pointer class for automatic garbage collection.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Matrix Market file utilities.
"Raw" input of sparse matrices from Matrix Market files.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...