linbox
Public Member Functions
MatrixStream< Field > Class Template Reference

MatrixStream. More...

#include <matrix-stream.h>

Public Member Functions

 MatrixStream (const Field &fld, std::istream &in)
 Constructor from an input stream. More...
 
 ~MatrixStream ()
 Destructor.
 
void newmatrix ()
 Re initiliaze after one matrix has been read. More...
 
bool readWhiteSpace ()
 Read some white space (if there is any). More...
 
bool nextTriple (size_t &, size_t &, Element &)
 Read the next triple of row index, column index, value and store it in the three referenced elements. More...
 
bool getArray (std::vector< Element > &array)
 Get the whole matrix as a dense (row-major) array of elements. More...
 
bool getRows (size_t &)
 Get the number of rows in the matrix and store it in the given size_t. More...
 
bool getColumns (size_t &)
 Get the number of columns in the matrix and store it in the given size_t. More...
 
bool getDimensions (size_t &, size_t &)
 Get the number of rows and columns in the matrix and store them in the given ints. More...
 
MatrixStreamError getError () const
 Get the current state of the stream. More...
 
MatrixStreamError reportError (const char *, int) const
 Report the error to the error stream and return it. More...
 
int getLineNumber () const
 If the reader is in the GOOD state, get the line number it is on. More...
 
const Field & getField () const
 Get the Field that was passed to the constructor. More...
 
const char * getFormat () const
 Get a brief description of the format of the matrix being read. More...
 
const char * getShortFormat () const
 Get a very brief description of the matrix format. More...
 
bool isSparse () const
 Tell if the matrix being read is sparse. More...
 

Detailed Description

template<class Field>
class LinBox::MatrixStream< Field >

MatrixStream.

Examples:
examples/checksolve.C, examples/doubledet.C, examples/omp_block_rank.C, examples/power_rank.C, examples/poweroftwo_ranks.C, examples/rank.C, examples/smithsparse.C, examples/smithvalence.C, examples/solve.C, examples/sparseelimrank.C, and examples/valence.C.

Constructor & Destructor Documentation

◆ MatrixStream()

MatrixStream ( const Field &  fld,
std::istream &  in 
)

Constructor from an input stream.

Parameters
fldThe Field used to read Elements from the matrix.
inThe input stream from which to read
Exceptions
MatrixStreamErrorif an error occurs in reading the first line (i.e. on initialization).

Member Function Documentation

◆ newmatrix()

void newmatrix ( )

Re initiliaze after one matrix has been read.

◆ readWhiteSpace()

bool readWhiteSpace ( )

Read some white space (if there is any).

Using this method is preferable to letting the input stream handle whitespace skipping because this method will update the line number when breaks are encountered.

Returns
true iff there is more data after the whitespace.

◆ nextTriple()

bool nextTriple ( size_t &  m,
size_t &  n,
Element &  v 
)

Read the next triple of row index, column index, value and store it in the three referenced elements.

Returns
true iff the read succeeded.

◆ getArray()

bool getArray ( std::vector< Element > &  array)

Get the whole matrix as a dense (row-major) array of elements.

Parameters
arrayThe array to fill with entries. May be resized as needed.

◆ getRows()

bool getRows ( size_t &  m)

Get the number of rows in the matrix and store it in the given size_t.

Returns
true iff the operation succeeded.

◆ getColumns()

bool getColumns ( size_t &  n)

Get the number of columns in the matrix and store it in the given size_t.

Returns
true iff the operation succeeded.

◆ getDimensions()

bool getDimensions ( size_t &  m,
size_t &  n 
)

Get the number of rows and columns in the matrix and store them in the given ints.

Returns
true iff the operation succeeded.

◆ getError()

MatrixStreamError getError ( ) const
inline

Get the current state of the stream.

Especially useful if called after nextTriple or one of the get operations on failure to get some information on what caused the failure.

◆ reportError()

MatrixStreamError reportError ( const char *  func,
int  line 
) const

Report the error to the error stream and return it.

Designed for throw operations.

◆ getLineNumber()

int getLineNumber ( ) const

If the reader is in the GOOD state, get the line number it is on.

Otherwise, get the line number on which the last error occurred.

◆ getField()

const Field& getField ( ) const
inline

Get the Field that was passed to the constructor.

◆ getFormat()

const char* getFormat ( ) const
inline

Get a brief description of the format of the matrix being read.

◆ getShortFormat()

const char* getShortFormat ( ) const
inline

Get a very brief description of the matrix format.

◆ isSparse()

bool isSparse ( ) const
inline

Tell if the matrix being read is sparse.

Returns
true if the matrix is sparse, false if it is dense.

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