#include <matrix-stream.h>
Inherited by DenseReader, MapleReader, MatrixMarketReader, SMSReader, and SparseRowReader.
Public Member Functions | |
virtual const char * | getName () const =0 |
virtual const char * | shortName () const |
virtual bool | isSparse () const =0 |
MatrixStreamError | init (const char *, std::istream *, MatrixStream< Field > *) |
MatrixStreamError | nextTriple (size_t &, size_t &, Element &) |
virtual MatrixStreamError | getArray (std::vector< Element > &array) |
MatrixStreamError | saveNext () |
MatrixStreamError | getRows (size_t &) |
MatrixStreamError | getColumns (size_t &) |
virtual | ~MatrixStreamReader () |
Protected Member Functions | |
void | saveTriple (size_t m, size_t n, const Element &v) |
virtual MatrixStreamError | nextTripleImpl (size_t &, size_t &, Element &)=0 |
virtual MatrixStreamError | initImpl (const char *firstLine)=0 |
MatrixStreamReader () | |
Protected Attributes | |
std::istream * | sin |
MatrixStream< Field > * | ms |
size_t | _m |
bool | knowM |
size_t | _n |
bool | knowN |
bool | atEnd |
MatrixStreamReader | ( | ) | [inline, protected] |
A protected constructor that is called automatically when subclasses are instantiated.
virtual ~MatrixStreamReader | ( | ) | [inline, virtual] |
Virtual destructor.
void saveTriple | ( | size_t | m, | |
size_t | n, | |||
const Element & | v | |||
) | [protected] |
Save the triple (m,n,v) onto the savedTriples std::queue.
virtual MatrixStreamError nextTripleImpl | ( | size_t & | , | |
size_t & | , | |||
Element & | ||||
) | [protected, pure virtual] |
Read the next triple of row index, column index, value and store it in the given references.
virtual MatrixStreamError initImpl | ( | const char * | firstLine | ) | [protected, pure virtual] |
Read the first line of the matrix from the stream and attempt to determine if it is of this reader's type.
virtual const char* getName | ( | ) | const [pure virtual] |
Get a unique string describing this format.
virtual const char* shortName | ( | ) | const [inline, virtual] |
Get a (possibly) shortened version of the format name.
virtual bool isSparse | ( | ) | const [pure virtual] |
Determine if this format is sparse or dense.
MatrixStreamError init | ( | const char * | , | |
std::istream * | , | |||
MatrixStream< Field > * | ||||
) |
Initialize this MatrixStreamReader. Calls the initImpl method of the subclass.
MatrixStreamError nextTriple | ( | size_t & | , | |
size_t & | , | |||
Element & | ||||
) |
Get the next triple of row index, column index, value and store it into the three referenced variables. Uses the nextTripleImpl method of the subclass.
virtual MatrixStreamError getArray | ( | std::vector< Element > & | array | ) | [virtual] |
Get the whole matrix as a dense (row-major) array of elements. By default, this implementation just repeatedly calls nextTriple to read in the whole matrix. Subclasses of dense formats should override this behavior.
array | The array to fill with entries. May be resized as needed. |
MatrixStreamError saveNext | ( | ) |
Reads the next triple from the subclass nextTripleImpl method and saves it to the savedTriples std::queue rather than returning it. The error returned is that given from the subclass method.
MatrixStreamError getRows | ( | size_t & | ) |
Get the number of rows in this matrix, store it in the given int.
MatrixStreamError getColumns | ( | size_t & | ) |
Get the number of columns in this matrix, store it in the given int.
std::istream* sin [protected] |
The stream that provides the data to the reader.
A pointer to the MatrixStream that is using this reader. Useful to get an instance of the field via ms->getField().
size_t _m [protected] |
The number of rows in the matrix. This will be set by default to 0.
bool knowM [protected] |
Indicates whether the row dimension is accurate
size_t _n [protected] |
Number of columns in the matrix. Similar requirements as _m above.
bool knowN [protected] |
Indicates whether the column dimension is accurate
bool atEnd [protected] |
Indicates that the end of the matrix has been reached; no more calls to nextTripleImpl will be made once this value is true. This will automatically be set to true if nextTripleImpl returns END_OF_MATRIX.