|
linbox
|
An abstract base class to represent readers for specific formats. More...
#include <matrix-stream.h>
Public Member Functions | |
| virtual const char * | getName () const =0 |
| Get a unique string describing this format. | |
| virtual const char * | shortName () const |
| Get a (possibly) shortened version of the format name. | |
| virtual bool | isSparse () const =0 |
| Determine if this format is sparse or dense. | |
| MatrixStreamError | init (const char *, std::istream *, MatrixStream< Field > *) |
| Initialize this MatrixStreamReader. | |
| 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. | |
| template<class Vect> | |
| MatrixStreamError | getArray (Vect &array) |
| Get the whole matrix as a dense (row-major) array of elements. | |
| MatrixStreamError | saveNext () |
| Reads the next triple from the subclass nextTripleImpl method and saves it to the savedTriples std::queue rather than returning it. | |
| 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. | |
| virtual | ~MatrixStreamReader () |
| Virtual destructor. | |
Protected Member Functions | |
| void | saveTriple (size_t m, size_t n, const Element &v) |
| Save the triple (m,n,v) onto the savedTriples std::queue. | |
| virtual MatrixStreamError | nextTripleImpl (size_t &, size_t &, Element &)=0 |
| Read the next triple of row index, column index, value and store it in the given references. | |
| virtual MatrixStreamError | initImpl (const char *firstLine)=0 |
| Read the first line of the matrix from the stream and attempt to determine if it is of this reader's type. | |
| MatrixStreamReader () | |
| A protected constructor that is called automatically when subclasses are instantiated. | |
Protected Attributes | |
| std::istream * | sin |
| The stream that provides the data to the reader. | |
| MatrixStream< Field > * | ms |
| A pointer to the MatrixStream that is using this reader. | |
| size_t | _m |
| The number of rows in the matrix. | |
| bool | knowM |
| Indicates whether the row dimension is accurate. | |
| size_t | _n |
| Number of columns in the matrix. | |
| bool | knowN |
| Indicates whether the column dimension is accurate. | |
| bool | atEnd |
| Indicates that the end of the matrix has been reached; no more calls to nextTripleImpl will be made once this value is true. | |
An abstract base class to represent readers for specific formats.
For each format that is to be supported, make an extension of this class that implements protected methods nextTripleImpl and initImpl.
|
protectedpure virtual |
Read the next triple of row index, column index, value and store it in the given references.
|
protectedpure virtual |
Read the first line of the matrix from the stream and attempt to determine if it is of this reader's type.
|
pure virtual |
Determine if this format is sparse or dense.
| MatrixStreamError init | ( | const char * | firstLine, |
| std::istream * | i, | ||
| MatrixStream< Field > * | m ) |
Initialize this MatrixStreamReader.
Calls the initImpl method of the subclass.
| MatrixStreamError nextTriple | ( | size_t & | m, |
| size_t & | n, | ||
| Element & | v ) |
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.
| MatrixStreamError getArray | ( | Vect & | array | ) |
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. Vect type must ensure that the vector is resizable |
| 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.
|
protected |
A pointer to the MatrixStream that is using this reader.
Useful to get an instance of the field via ms->getField().
|
protected |
The number of rows in the matrix.
This will be set by default to 0.
|
protected |
Number of columns in the matrix.
Similar requirements as _m above.
|
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.