linbox
Public Member Functions
SparseMatrix Class Reference

vector of sparse rows. More...

#include <sparse.h>

+ Inheritance diagram for SparseMatrix:

Public Member Functions

 SparseMatrix (const Field &F, size_t m=0, size_t n=0)
 Constructor.
template<class VectStream >
 SparseMatrix (const Field &F, VectStream &stream)
 Constructor from a vector stream.
 SparseMatrix (MatrixStream< Field > &ms)
 Constructor from a MatrixStream.
 SparseMatrix (const SparseMatrix< Field, Row > &B)
 Copy constructor.
template<class VectorType >
 SparseMatrix (const SparseMatrix< Field, VectorType > &B)
 Row type Converter constructor.
 ~SparseMatrix ()
 Destructor.
template<class OutVector , class InVector >
OutVector & apply (OutVector &y, const InVector &x) const
 Matrix-vector product $y = A x$.
template<class OutVector , class InVector >
OutVector & applyTranspose (OutVector &y, const InVector &x) const
 Transpose matrix-vector product $ y = A^T x$.
size_t rowdim () const
 Retreive row dimensions of Sparsemat matrix.
size_t coldim () const
 Retreive column dimensions of Sparsemat matrix.
std::istreamread (std::istream &is, FileFormatTag format=FORMAT_DETECT)
 Read the matrix from a stream in the given format.
std::ostreamwrite (std::ostream &os, FileFormatTag format=FORMAT_PRETTY) const
 Write the matrix to a stream in the given format.
const Field & field () const
 Access to the base field.
size_t size () const
 Retreive number of elements in the matrix.
std::istreamread (std::istream &is, const Field &F, FileFormatTag format=FORMAT_DETECT)
 Read a matrix from the given input stream using field read/write.
std::ostreamwrite (std::ostream &os, const Field &F, FileFormatTag format=FORMAT_PRETTY) const
 Write a matrix to the given output stream using field read/write.
void setEntry (size_t i, size_t j, const Element &value)
 Set an individual entry Setting the entry to 0 will remove it from the matrix.
Element & refEntry (size_t i, size_t j)
 Get a writeable reference to an entry in the matrix If there is no entry at the position (i, j), then a new entry with a value of zero is inserted and a reference to it is returned.
const Element & getEntry (size_t i, size_t j) const
 Get a read-only individual entry from the matrix.
Element & getEntry (Element &x, size_t i, size_t j) const
 Get an entry and store it in the given value This form is more in the Linbox style and is provided for interface compatibility with other parts of the library.
Raw iterator

The raw iterator is a method for accessing all nonzero entries in the matrix in some unspecified order.

This can be used, e.g. to reduce all matrix entries modulo a prime before passing the matrix into an algorithm.

Iterator Begin ()
 Begin.
ConstIterator Begin () const
 const Begin.
Iterator End ()
 End.
ConstIterator End () const
 const End

Columns of rows iterator

The columns of row iterator gives each of the rows of the matrix in ascending order.

Dereferencing the iterator yields a row vector in sparse sequence format

typedef Rep::iterator RowIterator
typedef Rep::const_iterator ConstRowIterator
RowIterator rowBegin ()
ConstRowIterator rowBegin () const
RowIterator rowEnd ()
ConstRowIterator rowEnd () const

Index iterator

The index iterator gives the row, column indices of all matrix elements in the same order as the raw iterator above.

Its value type is an STL pair with the row and column indices, starting at 0, in the first and second positions, respectively.

Rep _A
 IndexedBegin.
size_t _m
 IndexedBegin.
size_t _n
 IndexedBegin.
class SparseMatrixWriteHelper< Element, Row >
 IndexedBegin.
class SparseMatrixReadWriteHelper< Element, Row >
 IndexedBegin.
IndexedIterator IndexedBegin ()
 IndexedBegin.
ConstIndexedIterator IndexedBegin () const
 const IndexedBegin
IndexedIterator IndexedEnd ()
 IndexedEnd.
ConstIndexedIterator IndexedEnd () const
 const IndexedEnd
Row & getRow (size_t i)
 Retrieve a row as a writeable reference.
Row & operator[] (size_t i)
 Retrieve a row as a writeable reference.
ConstRow & operator[] (size_t i) const
 Retrieve a row as a read-only reference.
Vector & columnDensity (Vector &v) const
 Compute the column density, i.e the number of entries per column.
SparseMatrixBasetranspose (SparseMatrixBase &AT) const
 Construct the transpose of this matrix and place it in the matrix given.

Detailed Description

vector of sparse rows.

This is a generic black box for a sparse matrix. It inherits LinBox::SparseMatrixBase, which implements all of the underlying accessors and iterators.

Examples:

examples/det.C, examples/minpoly.C, examples/rank.C, examples/smith.C, examples/smithvalence.C, examples/solve.C, examples/sparseelimdet.C, examples/sparseelimrank.C, and examples/valence.C.


Constructor & Destructor Documentation

SparseMatrix ( const Field &  F,
size_t  m = 0,
size_t  n = 0 
) [inline]

Constructor.

Builds a zero m x n matrix Note: the copy constructor and operator= will work as intended because of STL's container design

Parameters:
FField over which entries exist
mRow dimension
nColumn dimension
SparseMatrix ( const Field &  F,
VectStream &  stream 
) [inline]

Constructor from a vector stream.

Parameters:
FField over which entries exist
streamStream with which to generate row vectors
SparseMatrix ( MatrixStream< Field > &  ms) [inline]

Constructor from a MatrixStream.

Parameters:
msA matrix stream properly initialized
~SparseMatrix ( ) [inline]

Destructor.


Member Function Documentation

OutVector& apply ( OutVector &  y,
const InVector &  x 
) const [inline]

Matrix-vector product $y = A x$.

Returns:
reference to output vector y
Parameters:
xinput vector
y
Examples:
examples/solve.C.
OutVector& applyTranspose ( OutVector &  y,
const InVector &  x 
) const [inline]

Transpose matrix-vector product $ y = A^T x$.

Returns:
reference to output vector y
Parameters:
xinput vector
y
size_t rowdim ( ) const [inline]

Retreive row dimensions of Sparsemat matrix.

Returns:
integer number of rows of SparseMatrix0Base matrix.

Reimplemented from SparseMatrixBase< _Field::Element, _Row >.

Examples:
examples/det.C, examples/rank.C, examples/solve.C, examples/sparseelimdet.C, and examples/sparseelimrank.C.
size_t coldim ( ) const [inline]

Retreive column dimensions of Sparsemat matrix.

Returns:
integer number of columns of SparseMatrix0Base matrix.

Reimplemented from SparseMatrixBase< _Field::Element, _Row >.

Examples:
examples/det.C, examples/rank.C, examples/solve.C, examples/sparseelimdet.C, and examples/sparseelimrank.C.
std::istream& read ( std::istream is,
FileFormatTag  format = FORMAT_DETECT 
) [inline]

Read the matrix from a stream in the given format.

Parameters:
isInput stream from which to read the matrix
formatFormat of input matrix
Returns:
Reference to input stream

Reimplemented from SparseMatrixBase< _Field::Element, _Row >.

std::ostream& write ( std::ostream os,
FileFormatTag  format = FORMAT_PRETTY 
) const [inline]

Write the matrix to a stream in the given format.

Parameters:
osOutput stream to which to write the matrix
formatFormat of output
Returns:
Reference to output stream

Reimplemented from SparseMatrixBase< _Field::Element, _Row >.

Examples:
examples/rank.C, examples/sparseelimdet.C, and examples/sparseelimrank.C.
size_t size ( ) const [inline, inherited]

Retreive number of elements in the matrix.

Returns:
integer number of elements of SparseMatrixBase matrix.
std::istream& read ( std::istream is,
const Field F,
FileFormatTag  format = FORMAT_DETECT 
) [inherited]

Read a matrix from the given input stream using field read/write.

Parameters:
isInput stream from which to read the matrix
FField with which to read
formatFormat of input matrix
std::ostream& write ( std::ostream os,
const Field F,
FileFormatTag  format = FORMAT_PRETTY 
) const [inherited]

Write a matrix to the given output stream using field read/write.

Parameters:
osOutput stream to which to write the matrix
FField with which to write
formatFormat with which to write
void setEntry ( size_t  i,
size_t  j,
const Element &  value 
) [inherited]

Set an individual entry Setting the entry to 0 will remove it from the matrix.

Parameters:
iRow index of entry
jColumn index of entry
valueValue of the new entry
Element& refEntry ( size_t  i,
size_t  j 
) [inherited]

Get a writeable reference to an entry in the matrix If there is no entry at the position (i, j), then a new entry with a value of zero is inserted and a reference to it is returned.

Parameters:
iRow index of entry
jColumn index of entry
Returns:
Reference to matrix entry
const Element& getEntry ( size_t  i,
size_t  j 
) const [inherited]

Get a read-only individual entry from the matrix.

Parameters:
iRow index
jColumn index
Returns:
Const reference to matrix entry
Element& getEntry ( Element &  x,
size_t  i,
size_t  j 
) const [inherited]

Get an entry and store it in the given value This form is more in the Linbox style and is provided for interface compatibility with other parts of the library.

Parameters:
xElement in which to store result
iRow index
jColumn index
Returns:
Reference to x
Row& getRow ( size_t  i) [inherited]

Retrieve a row as a writeable reference.

Parameters:
iRow index
Row& operator[] ( size_t  i) [inherited]

Retrieve a row as a writeable reference.

Parameters:
iRow index
ConstRow& operator[] ( size_t  i) const [inherited]

Retrieve a row as a read-only reference.

Parameters:
iRow index
Vector& columnDensity ( Vector &  v) const [inherited]

Compute the column density, i.e the number of entries per column.

Parameters:
vVector in which to store column density
SparseMatrixBase& transpose ( SparseMatrixBase< _Field::Element, _Row > &  AT) const [inherited]

Construct the transpose of this matrix and place it in the matrix given.

Parameters:
AT

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