Represents a sparse 2D matrix. More...
#include <sparse_matrix.hh>
Classes | |
class | element |
Element of sparse matrix. More... | |
Public Types | |
typedef T | value_t |
type of matrix entries | |
typedef size_t | size_type |
usual definition of size_type | |
typedef std::pair< size_type, size_type > | key_t |
type of matrix index pair | |
typedef map_t::const_iterator | const_iterator |
Stl-compatible constant iterator over matrix elements. | |
Public Member Functions | |
SparseMatrix () | |
Empty constructor (with default default value) | |
SparseMatrix (const value_t &def) | |
Construct with default value. | |
element | operator() (size_type i, size_type j) |
Access to matrix element. | |
const value_t & | operator() (size_type i, size_type j) const |
Read-only access to matrix element of const matrix. | |
void | set (size_type i, size_type j, const value_t &val) |
Write access to matrix entry. | |
value_t & | ref (size_type i, size_type j) |
Write access to matrix element of const matrix. | |
void | reset (size_type i, size_type j) |
Set matrix entry to default value. | |
size_type | size () const |
Size of sparse matrix. | |
bool | empty () const |
Check for emptiness. | |
void | clear () |
Clear the matrix. | |
const_iterator | begin () const |
Begin const iterator over matrix entries. | |
const_iterator | end () const |
End const iterator over matrix entries. | |
const value_t & | def () const |
Default value. | |
Protected Types | |
typedef unordered_map< key_t, value_t, pair_of_size_t_hash > ::type | map_t |
map type | |
Protected Attributes | |
map_t | the_map_ |
internal representation of sparse matrix | |
value_t | def_ |
default value of matrix entries |
Represents a sparse 2D matrix.
Sparse matrix of entries val_t implements the matrix by a hash map. The class is designed to be largely exchangable with the non-sparse Matrix class. (A proxy class is used to provide the same syntax for the interface.)
typedef map_t::const_iterator LocARNA::SparseMatrix< T >::const_iterator |
Stl-compatible constant iterator over matrix elements.
Behaves like a const iterator of the hash map.
LocARNA::SparseMatrix< T >::SparseMatrix | ( | const value_t & | def | ) | [inline, explicit] |
Construct with default value.
def | default value of entries |
const_iterator LocARNA::SparseMatrix< T >::begin | ( | ) | const [inline] |
Begin const iterator over matrix entries.
const value_t& LocARNA::SparseMatrix< T >::def | ( | ) | const [inline] |
Default value.
bool LocARNA::SparseMatrix< T >::empty | ( | ) | const [inline] |
Check for emptiness.
const_iterator LocARNA::SparseMatrix< T >::end | ( | ) | const [inline] |
End const iterator over matrix entries.
element LocARNA::SparseMatrix< T >::operator() | ( | size_type | i, |
size_type | j | ||
) | [inline] |
Access to matrix element.
i | index first dimension |
j | index second dimension |
const value_t& LocARNA::SparseMatrix< T >::operator() | ( | size_type | i, |
size_type | j | ||
) | const [inline] |
Read-only access to matrix element of const matrix.
i | index first dimension |
j | index second dimension |
value_t& LocARNA::SparseMatrix< T >::ref | ( | size_type | i, |
size_type | j | ||
) | [inline] |
Write access to matrix element of const matrix.
i | index first dimension |
j | index second dimension |
void LocARNA::SparseMatrix< T >::reset | ( | size_type | i, |
size_type | j | ||
) | [inline] |
Set matrix entry to default value.
i | index first dimension |
j | index second dimension |
void LocARNA::SparseMatrix< T >::set | ( | size_type | i, |
size_type | j, | ||
const value_t & | val | ||
) | [inline] |
Write access to matrix entry.
i | index first dimension |
j | index second dimension |
val | value to be written to entry (i,j) |
size_type LocARNA::SparseMatrix< T >::size | ( | ) | const [inline] |
Size of sparse matrix.