Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Public Member Functions | Private Member Functions | Private Attributes
Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal > Class Template Reference

Read a sparse matrix from a Matrix Market file into raw CSR (compressed sparse row) storage. More...

#include <Teuchos_MatrixMarket_Raw_Reader.hpp>

List of all members.

Public Member Functions

 Reader (const bool tolerant, const bool debug)
 Constructor that takes Boolean parameters.
 Reader ()
 Constructor that sets default Boolean parameters.
 Reader (const RCP< ParameterList > &params)
 Constructor that takes a ParameterList of parameters.
void setParameters (const RCP< ParameterList > &params)
 Set parameters from the given ParameterList.
RCP< const ParameterListgetValidParameters () const
 Get a list of valid default parameters, with documentation.
bool readFile (ArrayRCP< Ordinal > &rowptr, ArrayRCP< Ordinal > &colind, ArrayRCP< Scalar > &values, Ordinal &numRows, Ordinal &numCols, const std::string &filename)
 Read the sparse matrix from the given file into CSR storage.
bool read (ArrayRCP< Ordinal > &rowptr, ArrayRCP< Ordinal > &colind, ArrayRCP< Scalar > &values, Ordinal &numRows, Ordinal &numCols, std::istream &in)
 Read the sparse matrix from the given input stream into CSR storage.

Private Member Functions

void init ()
 "Initialize" the Reader.
RCP< const BannerreadBanner (std::istream &in, size_t &lineNumber)
 Read in the Banner line from the given input stream.
void reportBadness (std::ostream &out, const std::pair< bool, std::vector< size_t > > &results)

Private Attributes

bool tolerant_
 Whether to parse the Matrix Market file tolerantly.
bool debug_
 Whether to print debugging output to stderr.

Detailed Description

template<class Scalar, class Ordinal>
class Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >

Read a sparse matrix from a Matrix Market file into raw CSR (compressed sparse row) storage.

Template Parameters:
ScalarThe type of entries of the sparse matrix.
OrdinalThe type of indices of the sparse matrix.

This class is useful for benchmarking local sparse kernels. It should only be called by one MPI process at a time and is not aware of parallel communication. Use Tpetra::MatrixMarket::Reader if you want to read a Tpetra::CrsMatrix from a Matrix Market file.

Definition at line 101 of file Teuchos_MatrixMarket_Raw_Reader.hpp.


Constructor & Destructor Documentation

template<class Scalar , class Ordinal >
Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::Reader ( const bool  tolerant,
const bool  debug 
) [inline]

Constructor that takes Boolean parameters.

Parameters:
tolerant[in] Whether to parse the Matrix Market files tolerantly.
debug[in] Whether to print (possibly copious) debugging output to stderr.

Definition at line 109 of file Teuchos_MatrixMarket_Raw_Reader.hpp.

template<class Scalar , class Ordinal >
Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::Reader ( ) [inline]

Constructor that sets default Boolean parameters.

Definition at line 116 of file Teuchos_MatrixMarket_Raw_Reader.hpp.

template<class Scalar , class Ordinal >
Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::Reader ( const RCP< ParameterList > &  params) [inline]

Constructor that takes a ParameterList of parameters.

Parameters (all of them have type bool, all default to false):

  • "Parse tolerantly": Whether to parse Matrix Market files tolerantly.
  • "Debug mode": Whether to print (possibly copious) debugging output to stderr.

Definition at line 129 of file Teuchos_MatrixMarket_Raw_Reader.hpp.


Member Function Documentation

template<class Scalar , class Ordinal >
void Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::setParameters ( const RCP< ParameterList > &  params) [inline]

Set parameters from the given ParameterList.

See constructor documentation for the accepted parameters.

Definition at line 140 of file Teuchos_MatrixMarket_Raw_Reader.hpp.

template<class Scalar , class Ordinal >
RCP<const ParameterList> Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::getValidParameters ( ) const [inline]

Get a list of valid default parameters, with documentation.

Definition at line 158 of file Teuchos_MatrixMarket_Raw_Reader.hpp.

template<class Scalar , class Ordinal >
bool Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::readFile ( ArrayRCP< Ordinal > &  rowptr,
ArrayRCP< Ordinal > &  colind,
ArrayRCP< Scalar > &  values,
Ordinal &  numRows,
Ordinal &  numCols,
const std::string &  filename 
) [inline]

Read the sparse matrix from the given file into CSR storage.

The outputs rowptr, colind, values together form the common three-arrays representation of compressed sparse row (CSR) storage.

Parameters:
rowptr[out] Array of numRows+1 offsets, where numRows is the number of rows in the sparse matrix. For row i (zero-based indexing), the entries of that row are in indices rowptr[i] .. rowptr[i+1]-1 of colind and values.
colind[out] Column indices of the matrix. Same number of entries as values. colind[k] is the column index of values[k].
values[out] Values stored in the matrix.
numRows[out] Number of rows in the sparse matrix. This is redundant, because rowptr.size() == numRows on output.
numCols[out] Number of columns in the sparse matrix.
filename[in] Name of the Matrix Market file from which to read the sparse matrix.
Returns:
If parsing tolerantly: false if the Matrix Market file has any syntax errors, else true. If not parsing tolerantly, this should always return true.

Definition at line 200 of file Teuchos_MatrixMarket_Raw_Reader.hpp.

template<class Scalar , class Ordinal >
bool Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::read ( ArrayRCP< Ordinal > &  rowptr,
ArrayRCP< Ordinal > &  colind,
ArrayRCP< Scalar > &  values,
Ordinal &  numRows,
Ordinal &  numCols,
std::istream &  in 
) [inline]

Read the sparse matrix from the given input stream into CSR storage.

The outputs rowptr, colind, values together form the common three-arrays representation of compressed sparse row (CSR) storage.

Parameters:
rowptr[out] Array of numRows+1 offsets, where numRows is the number of rows in the sparse matrix. For row i (zero-based indexing), the entries of that row are in indices rowptr[i] .. rowptr[i+1]-1 of colind and values.
colind[out] Column indices of the matrix. Same number of entries as values. colind[k] is the column index of values[k].
values[out] Values stored in the matrix.
numRows[out] Number of rows in the sparse matrix. This is redundant, because rowptr.size() == numRows on output.
numCols[out] Number of columns in the sparse matrix.
in[in/out] Input stream from which to read the sparse matrix.
Returns:
If parsing tolerantly: false if the Matrix Market file has any syntax errors, else true. If not parsing tolerantly, this should always return true.

Definition at line 240 of file Teuchos_MatrixMarket_Raw_Reader.hpp.

template<class Scalar , class Ordinal >
void Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::init ( ) [inline, private]

"Initialize" the Reader.

Right now, this means print debugging output on creation of the Reader, if the user selected that option. We put this into a function to avoid duplicated debugging output code in the different constructors.

Definition at line 438 of file Teuchos_MatrixMarket_Raw_Reader.hpp.

template<class Scalar , class Ordinal >
RCP<const Banner> Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::readBanner ( std::istream &  in,
size_t &  lineNumber 
) [inline, private]

Read in the Banner line from the given input stream.

Parameters:
in[in/out] Input stream from which to read the Banner line. This must be valid on the calling process.
lineNumber[in/out] On input: Current line number of the input stream. On output: if any line(s) were successfully read from the input stream, this is incremented by the number of line(s) read. (This includes comment lines.)
Returns:
The Matrix Market file's Banner line (never null).

Definition at line 462 of file Teuchos_MatrixMarket_Raw_Reader.hpp.

template<class Scalar , class Ordinal >
void Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::reportBadness ( std::ostream &  out,
const std::pair< bool, std::vector< size_t > > &  results 
) [inline, private]

Report syntax errors in the input stream's sparse matrix data.

Parameters:
out[in/out] Output stream to which to report.
results[in] Return value of CoordDataReader's read() method.

Definition at line 520 of file Teuchos_MatrixMarket_Raw_Reader.hpp.


Member Data Documentation

template<class Scalar , class Ordinal >
bool Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::tolerant_ [private]

Whether to parse the Matrix Market file tolerantly.

Definition at line 428 of file Teuchos_MatrixMarket_Raw_Reader.hpp.

template<class Scalar , class Ordinal >
bool Teuchos::MatrixMarket::Raw::Reader< Scalar, Ordinal >::debug_ [private]

Whether to print debugging output to stderr.

Definition at line 430 of file Teuchos_MatrixMarket_Raw_Reader.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines