linbox
Data Structures | Public Types | Public Member Functions | Data Fields
SparseMatrix< _Field, SparseMatrixFormat::CSR > Class Template Reference

Sparse matrix, Coordinate storage. More...

#include <sparse-csr-matrix.h>

+ Collaboration diagram for SparseMatrix< _Field, SparseMatrixFormat::CSR >:

Data Structures

class  IndexedIterator
 a forward iterator. More...
 

Public Types

typedef _Field Field
 Field.
 
typedef _Field::Element Element
 Element.
 
typedef SparseMatrixFormat::CSR Storage
 Matrix Storage Format.
 
typedef SparseMatrix< _Field, StorageSelf_t
 Self type.
 
typedef Vector< Field >::SparseSeq Row
 

Public Member Functions

 SparseMatrix (const _Field &F)
 Constructors. More...
 
template<class VectStream >
 SparseMatrix (const _Field &F, VectStream &stream)
 
template<class _OtherStorage >
 SparseMatrix (const SparseMatrix< _Field, _OtherStorage > &S)
 Default converter. More...
 
void importe (const SparseMatrix< _Field, SparseMatrixFormat::COO > &S)
 Conversions. More...
 
void importe (const SparseMatrix< _Field, SparseMatrixFormat::CSR > &S)
 Import a matrix in CSR format to CSR. More...
 
SparseMatrix< _Field, SparseMatrixFormat::CSR > & exporte (SparseMatrix< _Field, SparseMatrixFormat::CSR > &S)
 Export a matrix in CSR format from COO. More...
 
void transposeIn ()
 In place transpose. More...
 
Self_ttranspose (Self_t &S) const
 Transpose the matrix. More...
 
size_t rowdim () const
 number of rows. More...
 
size_t coldim () const
 number of columns. More...
 
size_t size () const
 Number of non zero elements in the matrix. More...
 
constElementgetEntry (const size_t &i, const size_t &j) const
 Get a read-only individual entry from the matrix. More...
 
void finalize ()
 make matrix ready to use after a sequence of setEntry calls.
 
const ElementsetEntry (const size_t &i, const size_t &j, const Element &e)
 Set an individual entry. More...
 
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. More...
 
std::istream & read (std::istream &is, Tag::FileFormat format=Tag::FileFormat::Detect)
 Read a matrix from the given input stream using field read/write. More...
 
bool consistent () const
 

Data Fields

const typedef Element constElement
 const Element
 

Detailed Description

template<class _Field>
class LinBox::SparseMatrix< _Field, SparseMatrixFormat::CSR >

Sparse matrix, Coordinate storage.

Member Typedef Documentation

◆ Row

typedef Vector<Field>::SparseSeq Row
Warning
this is not the row type. Just used for streams.

Constructor & Destructor Documentation

◆ SparseMatrix() [1/3]

SparseMatrix ( const _Field &  F)
inline

Constructors.

Todo:
convert from other matrix.

◆ SparseMatrix() [2/3]

SparseMatrix ( const _Field &  F,
VectStream &  stream 
)
inline
Bug:
may be 0...

◆ SparseMatrix() [3/3]

SparseMatrix ( const SparseMatrix< _Field, _OtherStorage > &  S)
inline

Default converter.

Parameters
Sa sparse matrix in any storage.

Member Function Documentation

◆ importe() [1/2]

void importe ( const SparseMatrix< _Field, SparseMatrixFormat::COO > &  S)
inline

Conversions.

Any sparse matrix has a converter to/from CSR. A specialisation can skip the temporary CSR matrix created.

Import a matrix in COO format to CSR.

Parameters
SCOO matrix to be converted in CSR

◆ importe() [2/2]

void importe ( const SparseMatrix< _Field, SparseMatrixFormat::CSR > &  S)
inline

Import a matrix in CSR format to CSR.

Parameters
SCSR matrix to be converted in CSR

◆ exporte()

SparseMatrix<_Field,SparseMatrixFormat::CSR >& exporte ( SparseMatrix< _Field, SparseMatrixFormat::CSR > &  S)
inline

Export a matrix in CSR format from COO.

Parameters
SCSR matrix to be converted from COO

◆ transposeIn()

void transposeIn ( )
inline

In place transpose.

Not quite...

◆ transpose()

Self_t& transpose ( Self_t S) const
inline

Transpose the matrix.

Parameters
S[out] transpose of self.
Returns
a reference to S.

◆ rowdim()

size_t rowdim ( ) const
inline

number of rows.

Returns
row dimension.

◆ coldim()

size_t coldim ( ) const
inline

number of columns.

Returns
column dimension

◆ size()

size_t size ( ) const
inline

Number of non zero elements in the matrix.

or at least the size of the _data if

Returns
size of the _data.

◆ getEntry()

constElement& getEntry ( const size_t &  i,
const size_t &  j 
) const
inline

Get a read-only individual entry from the matrix.

Parameters
iRow _colid
jColumn _colid
Returns
Const reference to matrix entry

◆ setEntry()

const Element& setEntry ( const size_t &  i,
const size_t &  j,
const Element e 
)
inline

Set an individual entry.

Setting the entry to 0 will not remove it from the matrix

Parameters
iRow _colid of entry
jColumn _colid of entry
valueValue of the new entry
Todo:
make it faster if i is 0 or m-1 ?
Warning
if this is used to build a matrix and this matrix is "well formed", it can be sped up (no checking that the entry already exists).

◆ write()

std::ostream& write ( std::ostream &  os,
Tag::FileFormat  format = Tag::FileFormat::MatrixMarket 
) const
inline

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

Parameters
osOutput stream to which to write the matrix
formatFormat with which to write

◆ read()

std::istream& read ( std::istream &  is,
Tag::FileFormat  format = Tag::FileFormat::Detect 
)
inline

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
Returns
ref to is.

◆ consistent()

bool consistent ( ) const
inline

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