|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
Sparse vector stored as dual sorted arrays (indices + values). More...
#include <sparse_vector.hpp>
Classes | |
| class | const_iterator |
Public Types | |
| using | param_type = Parameters |
| using | orientation = typename Parameters::orientation |
| using | size_type = typename Parameters::size_type |
| using | value_type = Value |
| using | reference = Value& |
| using | const_reference = const Value& |
Public Member Functions | |
| sparse_vector () | |
| sparse_vector (size_type n) | |
| size_type | size () const |
| size_type | nnz () const |
| bool | empty () const |
| size_type | num_rows () const |
| Orientation-aware dimensions (same pattern as dense_vector). | |
| size_type | num_cols () const |
| value_type | operator() (size_type i) const |
| reference | operator[] (size_type i) |
| bool | exists (size_type i) const |
| void | insert (size_type i, const Value &v) |
| void | clear () |
| void | reserve (size_type nnz) |
| Reserve storage for nnz entries, so that many inserts don't reallocate. | |
| void | crop (magnitude_t< Value > threshold) |
| Drops the entries whose magnitude is below threshold, in place. | |
| const std::vector< size_type > & | indices () const |
| const std::vector< Value > & | values () const |
| const_iterator | begin () const |
| const_iterator | end () const |
Sparse vector stored as dual sorted arrays (indices + values).
Indices are maintained in sorted order for O(log n) lookup.
Index checks (#830), by the "check once" policy of #825/#826:
| using mtl::vec::sparse_vector< Value, Parameters >::const_reference = const Value& |
| using mtl::vec::sparse_vector< Value, Parameters >::orientation = typename Parameters::orientation |
| using mtl::vec::sparse_vector< Value, Parameters >::param_type = Parameters |
| using mtl::vec::sparse_vector< Value, Parameters >::reference = Value& |
| using mtl::vec::sparse_vector< Value, Parameters >::size_type = typename Parameters::size_type |
| using mtl::vec::sparse_vector< Value, Parameters >::value_type = Value |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
Drops the entries whose magnitude is below threshold, in place.
The threshold is a magnitude (the real type, for a complex Value). A NaN entry is kept: it is not below any threshold, and dropping it would hide it (#830). Taken by value: a reference could alias an entry, as in v.crop(v[1]), which the compaction overwrites.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Orientation-aware dimensions (same pattern as dense_vector).
|
inline |
|
inline |
|
inline |
Reserve storage for nnz entries, so that many inserts don't reallocate.
Out-of-order insertion still moves the later entries.
|
inline |
|
inline |