Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | List of all members
Teuchos::MatrixMarket::CoordPatternReader< Callback, Ordinal > Class Template Reference

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

#include <Teuchos_MatrixMarket_CoordDataReader.hpp>

Inheritance diagram for Teuchos::MatrixMarket::CoordPatternReader< Callback, Ordinal >:
Inheritance graph
[legend]

Public Member Functions

 CoordPatternReader (const Teuchos::RCP< Callback > &adder)
 Constructor with "adder" argument. More...
 
 CoordPatternReader ()
 No-argument constructor. More...
 
virtual ~CoordPatternReader ()
 Virtual destructor for safety and happy compilers. More...
 
- Public Member Functions inherited from Teuchos::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >
 CoordDataReaderBase (const Teuchos::RCP< Callback > &adder)
 Constructor with "adder" argument. More...
 
 CoordDataReaderBase ()
 No-argument constructor. More...
 
virtual ~CoordDataReaderBase ()
 Virtual destructor for safety and happy compilers. More...
 
void setAdder (const Teuchos::RCP< Callback > &adder)
 Set the Adder object. More...
 
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. More...
 
std::pair< Teuchos::Tuple
< Ordinal, 3 >, bool > 
readDimensions (std::istream &in, size_t &lineNumber, const bool tolerant=false)
 Read (numRows, numCols, numNonzeros). More...
 

Protected Member Functions

bool readLine (const std::string &theLine, const size_t lineNumber, const bool tolerant)
 Read in the data from a single line of the input stream. More...
 

Additional Inherited Members

- Protected Attributes inherited from Teuchos::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >
Teuchos::RCP< Callback > adder_
 Closure that knows how to add entries to the sparse graph or matrix. More...
 

Detailed Description

template<class Callback, class Ordinal>
class Teuchos::MatrixMarket::CoordPatternReader< Callback, Ordinal >

Coordinate-format sparse graph data reader.

Use this class to read in sparse graph data and add it to the sparse graph using your Callback implementation (see the documentation of CoordDataReaderBase). CoordDataReaderBase is sufficiently general that we can extend it to read in a sparse graph. "Pattern" refers to the Matrix Market keyword "pattern" that indicates a sparse graph.

Template Parameters
CallbackSame as the Callback template parameter of CoordDataReaderBase. The type of the callback (a.k.a. closure) for adding entries to the sparse graph.
OrdinalSame as the Ordinal template parameter of CoordDataReaderBase. The type of indices of the sparse graph.

If you have an existing sparse graph implementation to which you want to add entries, you'll either have to make it implement Callback's two-argument operator(), or write your own Callback implementation that wraps the sparse graph.

Definition at line 607 of file Teuchos_MatrixMarket_CoordDataReader.hpp.

Constructor & Destructor Documentation

template<class Callback , class Ordinal >
Teuchos::MatrixMarket::CoordPatternReader< Callback, Ordinal >::CoordPatternReader ( const Teuchos::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 in order to create the Callback instance, you need the graph dimensions. This is the case if your Callback wraps Tpetra::CrsGraph, for example.

Parameters
adder[in/out] Closure (a.k.a. callback) whose operator() adds an entry to the sparse graph on each invocation.

Definition at line 621 of file Teuchos_MatrixMarket_CoordDataReader.hpp.

template<class Callback , class Ordinal >
Teuchos::MatrixMarket::CoordPatternReader< Callback, Ordinal >::CoordPatternReader ( )
inline

No-argument constructor.

We offer this option in case the adder's constructor needs the graph 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 632 of file Teuchos_MatrixMarket_CoordDataReader.hpp.

template<class Callback , class Ordinal >
virtual Teuchos::MatrixMarket::CoordPatternReader< Callback, Ordinal >::~CoordPatternReader ( )
inlinevirtual

Virtual destructor for safety and happy compilers.

Definition at line 637 of file Teuchos_MatrixMarket_CoordDataReader.hpp.

Member Function Documentation

template<class Callback , class Ordinal >
bool Teuchos::MatrixMarket::CoordPatternReader< Callback, Ordinal >::readLine ( const std::string &  theLine,
const size_t  lineNumber,
const bool  tolerant 
)
inlineprotectedvirtual

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

Parameters
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.
Returns
In tolerant parsing mode (tolerant==true), then this method returns true if parsing the current line succeeded, else false. Otherwise, this method throws an exception (and does not invoke the adder) if parsing the current line did not succeed.

Subclasses must implement this method in order to read one entry of the sparse graph or matrix. Implementations should use the callback (adder_) to add the entry.

Note
To implementers: We defer implementation of this method to subclasses, because the callback for a graph will take different arguments than the callback for a matrix. Abstracting around that using templates isn't worth the trouble. (Remember you're reading from a file and parsing strings. Virtual method call overhead isn't significant by comparison.)

Implements Teuchos::MatrixMarket::CoordDataReaderBase< Callback, Ordinal >.

Definition at line 641 of file Teuchos_MatrixMarket_CoordDataReader.hpp.


The documentation for this class was generated from the following file: