1 #ifndef SPARSE_MATRIX_HH
2 #define SPARSE_MATRIX_HH
11 #include "sparse_vector_base.hh"
34 using key_type = std::pair<size_type, size_type>;
35 using map_type = std::unordered_map<key_type, value_type>;
55 typename parent_t::element_proxy
57 return typename parent_t::element_proxy(
this,
key_type(i, j));
92 for (
const auto &x: m) {
93 out <<
"(" << x.first.first <<
"," << x.first.second <<
") "
94 << x.second << std::endl;
Represents a sparse 2D matrix.
Definition: sparse_matrix.hh:27
std::pair< size_type, size_type > key_type
type of matrix index pair
Definition: sparse_matrix.hh:34
parent_t::element_proxy operator()(size_type i, size_type j)
Access to matrix element.
Definition: sparse_matrix.hh:56
T value_type
type of matrix entries
Definition: sparse_matrix.hh:33
SparseMatrix(const value_type &def)
Construct with default value.
Definition: sparse_matrix.hh:43
std::unordered_map< key_type, value_type > map_type
map type
Definition: sparse_matrix.hh:35
typename parent_t::size_type size_type
usual definition of size_type
Definition: sparse_matrix.hh:32
Base class template for sparse vector and matrix.
Definition: sparse_vector_base.hh:23
size_t size_type
usual definition of size_type
Definition: sparse_vector_base.hh:30
const value_type & def() const
Default value.
Definition: sparse_vector_base.hh:272
value_type & ref(const key_type &i)
Write access to element.
Definition: sparse_vector_base.hh:194
element_proxy operator[](const key_type &i)
Access to vector element.
Definition: sparse_vector_base.hh:143
void set(const key_type &i, const value_type &val)
Write access to vector entry.
Definition: sparse_vector_base.hh:175
void reset(const key_type &i)
Set vector entry to default value.
Definition: sparse_vector_base.hh:209
Definition: aligner.cc:15
std::ostream & operator<<(std::ostream &out, const AlignerRestriction &r)
Definition: aligner_restriction.hh:135
size_t size_type
general size type
Definition: aux.hh:120