|
Tpetra Matrix/Vector Services Version of the Day
|
Common functionality of a coordinate-format sparse matrix or graph data reader. More...
#include <MatrixMarket_CoordDataReader.hpp>

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 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). | |
Protected Member Functions | |
| virtual bool | readLine (const std::string &theLine, const size_t lineNumber, const bool tolerant)=0 |
| Read in the data from a single line of the input stream. | |
Protected Attributes | |
| RCP< Callback > | adder_ |
| Closure that knows how to add entries to the sparse graph or matrix. | |
Common functionality of a coordinate-format sparse matrix or graph data reader.
This class provides common functionality for reading coordinate-format sparse matrix or graph data from a Matrix Market file. In particular, this class does not depend on the Scalar type, so it works for both graph and matrix data.
| Callback | The type of a callback (a.k.a. closure) that knows how to add entries to the sparse graph or matrix. |
| Ordinal | The type of indices of the sparse graph or matrix. |
Definition at line 63 of file MatrixMarket_CoordDataReader.hpp.
| Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >::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 graph or matrix dimensions).
| adder | [in/out] Closure (a.k.a. callback) whose operator() adds an entry to the sparse graph or matrix on each invocation. |
Definition at line 79 of file MatrixMarket_CoordDataReader.hpp.
| Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >::CoordDataReaderBase | ( | ) | [inline] |
No-argument constructor.
We offer this option in case the adder's constructor needs the graph or 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 89 of file MatrixMarket_CoordDataReader.hpp.
| virtual Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >::~CoordDataReaderBase | ( | ) | [inline, virtual] |
Virtual destructor for safety and happy compilers.
Definition at line 92 of file MatrixMarket_CoordDataReader.hpp.
| void Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >::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 100 of file MatrixMarket_CoordDataReader.hpp.
| virtual bool Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >::readLine | ( | const std::string & | theLine, |
| const size_t | lineNumber, | ||
| const bool | tolerant | ||
| ) | [protected, pure virtual] |
Read in the data from a single line of the input stream.
| theLine | [in] The line read in from the input stream. |
| adder | [in/out] The callback to invoke for adding an entry to the sparse matrix. |
| lineNumber | [in] Current line number of the file. We use this for generating informative exception messages. |
| tolerant | [in] Whether to parse tolerantly. |
adder_) in your implementations of this method to add entries to the sparse graph or matrix.Implemented in Tpetra::MatrixMarket::CoordDataReader< Callback, Ordinal, Scalar, isComplex >, and Tpetra::MatrixMarket::CoordPatternReader< Callback, Ordinal >.
| virtual std::pair<bool, std::vector<size_t> > Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >::read | ( | std::istream & | in, |
| const size_t | startingLineNumber, | ||
| const bool | tolerant, | ||
| const bool | debug = false |
||
| ) | [inline, virtual] |
Read in all the data from the given input stream.
| 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 167 of file MatrixMarket_CoordDataReader.hpp.
| std::pair<Tuple<Ordinal, 3>, bool> Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >::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.
| in | [in/out] The input stream from which to attempt to read one line. |
| lineNumber | The 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). |
Definition at line 227 of file MatrixMarket_CoordDataReader.hpp.
RCP<Callback> Tpetra::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >::adder_ [protected] |
Closure that knows how to add entries to the sparse graph or matrix.
Definition at line 66 of file MatrixMarket_CoordDataReader.hpp.
1.7.4