42 #ifndef __Teuchos_MatrixMarket_Raw_Writer_hpp 
   43 #define __Teuchos_MatrixMarket_Raw_Writer_hpp 
   45 #include <Teuchos_SetScientific.hpp> 
   46 #include "Teuchos_ArrayView.hpp" 
   52   namespace MatrixMarket {
 
   66       template<
class ScalarType, 
class OrdinalType>
 
   95        const OrdinalType numRows,
 
   96        const OrdinalType numCols)
 
   98           std::ofstream out (filename.c_str ());
 
  100             "Failed to open file \"" << filename << 
"\" for writing.");
 
  101           write (out, rowptr, colind, values, numRows, numCols);
 
  134          const OrdinalType numRows,
 
  135          const OrdinalType numCols)
 
  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) {
 
  176       for (OrdinalType k = rowptr[i]; k < rowptr[i+1]; ++k) {
 
  177         const OrdinalType j = colind[k];
 
  178         const ScalarType& A_ij = values[k];
 
  181         out << (i+1) << 
" " << (j+1) << 
" ";
 
  182         if (STS::isComplex) {
 
  183     out << STS::real (A_ij) << 
" " << STS::imag (A_ij);
 
  196 #endif // __Teuchos_MatrixMarket_Raw_Writer_hpp 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging. 
Ordinal size_type
Type representing the number of elements in an ArrayRCP or view thereof. 
Temporarily make an output stream use scientific notation with sufficient precision. 
Templated Parameter List class. 
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. 
Write a sparse matrix from raw CSR (compressed sparse row) storage to a Matrix Market file...