Tpetra Matrix/Vector Services Version of the Day
Public Member Functions
Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal, Scalar, isComplex > Class Template Reference

Coordinate-format sparse matrix data reader. More...

#include <MatrixMarket_CoordDataReader.hpp>

Inheritance diagram for Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal, Scalar, isComplex >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CoordDataReaderBase (const RCP< Callback > &adder)
 Constructor with "adder" argument.
 CoordDataReaderBase ()
 No-argument constructor.
virtual ~CoordDataReaderBase ()
 Virtual destructor for safety and happy compilers.
void setAdder (const RCP< Callback > &adder)
 Set the Adder object.
virtual bool readLine (const std::string &theLine, Ordinal &rowIndex, Ordinal &colIndex, Scalar &value, const size_t lineNumber, const bool tolerant)=0
 Read in the data from a single line of the input stream.
std::pair< bool, std::vector
< size_t > > 
read (std::istream &in, const size_t startingLineNumber, const bool tolerant, const bool debug=false)
 Read in all the data from the given input stream.
std::pair< Tuple< Ordinal, 3 >
, bool > 
readDimensions (std::istream &in, size_t &lineNumber, const bool tolerant=false)
 Read (numRows, numCols, numNonzeros).

Detailed Description

template<class Callback, class Ordinal, class Scalar, bool isComplex = ScalarTraits<Scalar>::isComplex>
class Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal, Scalar, isComplex >

Coordinate-format sparse matrix data reader.

This class is an interface and partial implementation of reading coordinate-format sparse matrix data from a Matrix Market file. There are two concrete implementations: one for real-valued data, and the other for complex-valued data.

Definition at line 58 of file MatrixMarket_CoordDataReader.hpp.


Constructor & Destructor Documentation

template<class Callback, class Ordinal, class Scalar, bool isComplex = ScalarTraits<Scalar>::isComplex>
Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal, Scalar, isComplex >::CoordDataReaderBase ( const RCP< Callback > &  adder) [inline]

Constructor with "adder" argument.

This is the favored way to construct an instance of this type. Only use the no-argument constructor if you have a "chicken-and-egg" problem (where the adder needs the matrix dimensions).

Parameters:
adder[in/out] Closure whose operator() adds an entry to the sparse matrix on each invocation.

Definition at line 73 of file MatrixMarket_CoordDataReader.hpp.

template<class Callback, class Ordinal, class Scalar, bool isComplex = ScalarTraits<Scalar>::isComplex>
Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal, Scalar, isComplex >::CoordDataReaderBase ( ) [inline]

No-argument constructor.

We offer this option in case the adder's constructor needs the matrix dimensions, so that it's necessary to call readDimensions() first before constructing the adder. You should call setAdder() with a non-null argument before calling read() or readLine().

Definition at line 83 of file MatrixMarket_CoordDataReader.hpp.

template<class Callback, class Ordinal, class Scalar, bool isComplex = ScalarTraits<Scalar>::isComplex>
virtual Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal, Scalar, isComplex >::~CoordDataReaderBase ( ) [inline, virtual]

Virtual destructor for safety and happy compilers.

Definition at line 86 of file MatrixMarket_CoordDataReader.hpp.


Member Function Documentation

template<class Callback, class Ordinal, class Scalar, bool isComplex = ScalarTraits<Scalar>::isComplex>
void Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal, Scalar, isComplex >::setAdder ( const RCP< Callback > &  adder) [inline]

Set the Adder object.

Please don't call this after calling read() or readLine(). The right time to call this is right after calling the no-argument constructor, if it's not possible to supply an Adder object before calling readDimensions().

Definition at line 94 of file MatrixMarket_CoordDataReader.hpp.

template<class Callback, class Ordinal, class Scalar, bool isComplex = ScalarTraits<Scalar>::isComplex>
virtual bool Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal, Scalar, isComplex >::readLine ( const std::string &  theLine,
Ordinal &  rowIndex,
Ordinal &  colIndex,
Scalar &  value,
const size_t  lineNumber,
const bool  tolerant 
) [pure virtual]

Read in the data from a single line of the input stream.

This method has a different implementation, depending on whether Scalar is complex or not.

Implemented in Tpetra::MatrixMarket::CoordDataReader< Callback, Ordinal, Scalar, isComplex >.

template<class Callback, class Ordinal, class Scalar, bool isComplex = ScalarTraits<Scalar>::isComplex>
std::pair<bool, std::vector<size_t> > Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal, Scalar, isComplex >::read ( std::istream &  in,
const size_t  startingLineNumber,
const bool  tolerant,
const bool  debug = false 
) [inline]

Read in all the data from the given input stream.

Parameters:
in[in/out] The input stream from which to read
startingLineNumber[in] The line number of the file from which we begin reading. (This is used for informative error output, if an error is detected in the file.)
tolerant[in] If true, parse tolerantly. The resulting read-in data may be incorrect, but the parser won't throw an exception if it can just let bad data through and continue.
debug[in] If true, print verbose debugging output.

Definition at line 127 of file MatrixMarket_CoordDataReader.hpp.

template<class Callback, class Ordinal, class Scalar, bool isComplex = ScalarTraits<Scalar>::isComplex>
std::pair<Tuple<Ordinal, 3>, bool> Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal, Scalar, isComplex >::readDimensions ( std::istream &  in,
size_t &  lineNumber,
const bool  tolerant = false 
) [inline]

Read (numRows, numCols, numNonzeros).

Read one line from the given input stream, and parse it into the number of rows, the number of columns, and the number of nonzeros in the sparse matrix. We assume that those data are in whitespace-delimited format and are read from a Matrix Market - format file.

Parameters:
in[in/out] The input stream from which to attempt to read one line.
lineNumberThe starting line number from which we begin reading from the input stream. Used for diagnostic error output.
tolerant[in] Whether to read "tolerantly" (setting defaults and returning whether we were successful) or "intolerantly" (throwing an exception on any deviation from the expected format).
Returns:
((numRows, numCols, numNonzeros), success). In tolerant mode, success may be false, meaning that the read-in triple may not be valid.

Definition at line 202 of file MatrixMarket_CoordDataReader.hpp.


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