linbox
Public Member Functions
SparseMatrixGeneric< _Field, _Row, Trait > Class Template Reference

Sparse matrix container This class acts as a generic row-wise container for sparse matrices. More...

#include <sparse-generic.h>

Inherited by SparseMatrix< _Field, SparseMatrixFormat::SparseSeq >.

+ Collaboration diagram for SparseMatrixGeneric< _Field, _Row, Trait >:

Public Member Functions

 SparseMatrixGeneric (const Field &F, size_t m, size_t n)
 Constructor.
 
 SparseMatrixGeneric (MatrixStream< Field > &ms)
 Constructor from a MatrixStream.
 
 SparseMatrixGeneric (const SparseMatrixGeneric< Field, Row, Trait > &A)
 Copy constructor.
 
template<class VectorType >
 SparseMatrixGeneric (const SparseMatrixGeneric< Field, VectorType, Trait > &A)
 Convert constructor.
 
 ~SparseMatrixGeneric ()
 Destructor.
 
size_t rowdim () const
 Retreive row dimension of the matrix.
 
size_t coldim () const
 Retreive column dimension of matrix.
 
size_t size () const
 Retreive number of elements in the matrix.
 
std::istream & read (std::istream &is, Tag::FileFormat format=Tag::FileFormat::Detect)
 Read a matrix from the given input stream using field read/write.
 
std::ostream & write (std::ostream &os, Tag::FileFormat format=Tag::FileFormat::MatrixMarket) const
 Write a matrix to the given output stream using field read/write.
 
const Element & 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.
 
Iterator End ()
 End.
 
ConstIterator Begin () const
 const Begin.
 
ConstIterator End () const
 const End
 

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.

class SparseMatrixWriteHelper< Self_t >
 IndexedBegin.
 
class SparseMatrixReadHelper< Self_t >
 IndexedBegin.
 
Rep _matA
 IndexedBegin.
 
size_t _m
 IndexedBegin.
 
size_t _n
 IndexedBegin.
 
const Field & _field
 IndexedBegin.
 
MatrixDomain< Field > _MD
 IndexedBegin.
 
TransposeMatrix< SparseMatrixGeneric< _Field, _Row > > _AT
 IndexedBegin.
 
IndexedIterator IndexedBegin ()
 IndexedBegin.
 
IndexedIterator IndexedEnd ()
 IndexedEnd.
 
ConstIndexedIterator IndexedBegin () const
 const IndexedBegin
 
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.
 
template<class Vector >
VectorcolumnDensity (Vector &v) const
 Compute the column density, i.e the number of entries per column.
 
SparseMatrixGenerictranspose (SparseMatrixGeneric &AT) const
 Construct the transpose of this matrix and place it in the matrix given.
 
const Field & field () const
 IndexedBegin.
 
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$.
 
const Rep & getRep () const
 IndexedBegin.
 
Rep & refRep ()
 IndexedBegin.
 
void resize (const size_t &m, const size_t &n, const size_t &nnz=0)
 IndexedBegin.
 

Detailed Description

template<class _Field, class _Row, class Trait>
class LinBox::Protected::SparseMatrixGeneric< _Field, _Row, Trait >

Sparse matrix container This class acts as a generic row-wise container for sparse matrices.

It is designed to provide various methods to access the entries of the matrix. It meets the blackbox archetype

Template Parameters
_FieldField type
_RowLinBox sparse vector type to use for rows of matrix

Constructor & Destructor Documentation

◆ SparseMatrixGeneric()

template<class _Field , class _Row , class Trait >
SparseMatrixGeneric ( const Field &  F,
size_t  m,
size_t  n 
)
inline

Constructor.

Note: the copy constructor and operator= will work as intended because of STL's container design

Parameters
mrow dimension
ncolumn dimension

Member Function Documentation

◆ rowdim()

template<class _Field , class _Row , class Trait >
size_t rowdim ( ) const
inline

Retreive row dimension of the matrix.

Returns
integer number of rows of SparseMatrixGeneric matrix.

◆ coldim()

template<class _Field , class _Row , class Trait >
size_t coldim ( ) const
inline

Retreive column dimension of matrix.

Returns
integer number of columns of SparseMatrixGeneric matrix.

◆ size()

template<class _Field , class _Row , class Trait >
size_t size ( ) const
inline

Retreive number of elements in the matrix.

Returns
integer number of elements of SparseMatrixGeneric matrix.
Bug:
should it be elements or non zero elements ?
See also
ELL

◆ read()

template<class _Field , class _Row , class Trait >
std::istream & read ( std::istream &  is,
Tag::FileFormat  format = Tag::FileFormat::Detect 
)

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

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

◆ write()

template<class _Field , class _Row , class Trait >
std::ostream & write ( std::ostream &  os,
Tag::FileFormat  format = Tag::FileFormat::MatrixMarket 
) const

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

◆ setEntry()

template<class _Field , class _Row , class Trait >
const Field::Element & 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.

Parameters
iRow index of entry
jColumn index of entry
valueValue of the new entry

◆ refEntry()

template<class Field , class Row >
Field::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.

Parameters
iRow index of entry
jColumn index of entry
Returns
Reference to matrix entry

◆ getEntry() [1/2]

template<class Field , class Row >
const Field::Element & getEntry ( size_t  i,
size_t  j 
) const

Get a read-only individual entry from the matrix.

Parameters
iRow index
jColumn index
Returns
Const reference to matrix entry

◆ getEntry() [2/2]

template<class _Field , class _Row , class Trait >
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.

Parameters
xElement in which to store result
iRow index
jColumn index
Returns
Reference to x

◆ getRow()

template<class _Field , class _Row , class Trait >
Row & getRow ( size_t  i)

Retrieve a row as a writeable reference.

Parameters
iRow index

◆ operator[]() [1/2]

template<class _Field , class _Row , class Trait >
Row & operator[] ( size_t  i)

Retrieve a row as a writeable reference.

Parameters
iRow index

◆ operator[]() [2/2]

template<class _Field , class _Row , class Trait >
ConstRow & operator[] ( size_t  i) const

Retrieve a row as a read-only reference.

Parameters
iRow index

◆ columnDensity()

template<class Field , class Row >
template<class Vector >
Vector & columnDensity ( Vector v) const

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

Parameters
vVector in which to store column density

◆ transpose()

template<class Field , class Row >
SparseMatrixGeneric< Field, Row, VectorCategories::SparseSequenceVectorTag > & transpose ( SparseMatrixGeneric< _Field, _Row, Trait > &  AT) const

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

Parameters
AT

◆ apply()

template<class _Field , class _Row , class Trait >
template<class OutVector , class InVector >
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

◆ applyTranspose()

template<class _Field , class _Row , class Trait >
template<class OutVector , class InVector >
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

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