LocARNA-2.0.0
Public Types | Public Member Functions | Public Attributes | List of all members
LocARNA::SparseMatrix< T > Class Template Reference

Represents a sparse 2D matrix. More...

#include <sparse_matrix.hh>

Inheritance diagram for LocARNA::SparseMatrix< T >:
Inheritance graph
[legend]
Collaboration diagram for LocARNA::SparseMatrix< T >:
Collaboration graph
[legend]

Public Types

using parent_t = SparseVectorBase< SparseMatrix< T >, T, std::pair< size_t, size_t > >
 
using size_type = typename parent_t::size_type
 usual definition of size_type
 
using value_type = T
 type of matrix entries
 
using key_type = std::pair< size_type, size_type >
 type of matrix index pair
 
using map_type = std::unordered_map< key_type, value_type >
 map type
 
- Public Types inherited from LocARNA::SparseVectorBase< SparseMatrix< T >, T, std::pair< size_t, size_t > >
using derived_type = SparseMatrix< T >
 
using value_type = T
 type of vector entries
 
using key_type = std::pair< size_t, size_t >
 type of vector index
 
using map_type = std::unordered_map< std::pair< size_t, size_t >, T >
 
using size_type = size_t
 usual definition of size_type
 
using const_iterator = typename map_type::const_iterator
 Stl-compatible constant iterator over vector elements. More...
 
using iterator = typename map_type::iterator
 

Public Member Functions

 SparseMatrix (const value_type &def)
 Construct with default value. More...
 
parent_t::element_proxy operator() (size_type i, size_type j)
 Access to matrix element. More...
 
const value_typeoperator() (size_type i, size_type j) const
 
value_typeref (size_type i, size_type j)
 
void set (size_type i, size_type j, const value_type &val)
 
void reset (size_type i, size_type j)
 
- Public Member Functions inherited from LocARNA::SparseVectorBase< SparseMatrix< T >, T, std::pair< size_t, size_t > >
 SparseVectorBase (const value_type def)
 
element_proxy operator[] (const key_type &i)
 Access to vector element. More...
 
const value_typeoperator[] (const key_type &i) const
 Read-only access to vector element of const vector. More...
 
void set (const key_type &i, const value_type &val)
 Write access to vector entry. More...
 
value_typeref (const key_type &i)
 Write access to element. More...
 
void reset (const key_type &i)
 Set vector entry to default value. More...
 
size_type size () const
 Size of sparse vector. More...
 
bool empty () const
 Check for emptiness. More...
 
void clear ()
 Clear the vector.
 
const_iterator begin () const
 Begin const iterator over vector entries. More...
 
const_iterator end () const
 End const iterator over vector entries. More...
 
const value_typedef () const
 Default value. More...
 

Public Attributes

friend parent_t
 

Additional Inherited Members

- Protected Attributes inherited from LocARNA::SparseVectorBase< SparseMatrix< T >, T, std::pair< size_t, size_t > >
value_type def_
 default value of vector entries
 
map_type the_map_
 internal representation of sparse vector
 

Detailed Description

template<typename T>
class LocARNA::SparseMatrix< T >

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.)

See also
Matrix

Constructor & Destructor Documentation

◆ SparseMatrix()

template<typename T >
LocARNA::SparseMatrix< T >::SparseMatrix ( const value_type def)
inlineexplicit

Construct with default value.

Parameters
defdefault value of entries

Member Function Documentation

◆ operator()()

template<typename T >
parent_t::element_proxy LocARNA::SparseMatrix< T >::operator() ( size_type  i,
size_type  j 
)
inline

Access to matrix element.

Parameters
iindex first dimension
jindex second dimension
Returns
proxy to matrix entry (i,j)

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