MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::mat::compressed2D_inserter< Value, Parameters, Updater > Class Template Reference

RAII inserter for compressed2D. More...

#include <inserter.hpp>

Public Member Functions

 compressed2D_inserter (matrix_type &m, size_type slot_size=5)
 Construct inserter for matrix m with slot_size slots per row.
 ~compressed2D_inserter ()
 compressed2D_inserter (const compressed2D_inserter &)=delete
compressed2D_inserter & operator= (const compressed2D_inserter &)=delete
row_proxy operator[] (size_type row)

Detailed Description

template<typename Value, typename Parameters = parameters<>, typename Updater = update_store<Value>>
class mtl::mat::compressed2D_inserter< Value, Parameters, Updater >

RAII inserter for compressed2D.

Allocates flat working arrays with slot_size slots per row. Overflow entries go into a std::map. Destructor merges everything into the final sorted CSR arrays.

The inserter AMENDS the matrix, as MTL4's does (#825): the entries already in m are loaded into the slots at construction, so inserting at an existing position applies the updater to the stored value (update_store replaces it, update_plus adds to it) and every other entry is kept. To refill a matrix from scratch, empty it first (m.make_empty() or m.change_dim(r, c)). It used to rebuild the matrix from the inserter's own entries only, so a second inserter silently discarded everything before it.

Indices are checked in every build (#825): ins[r] with r outside [0, num_rows()) and ins[r][c] with c outside [0, num_cols()) throw std::out_of_range, via detail::throw_or_abort. The check has to happen at insertion – the row indexes the slot arrays straight away, and finalize() runs in the destructor, which must not throw – so it is one comparison per index, not a pass at the end.

Constructor & Destructor Documentation

◆ compressed2D_inserter() [1/2]

template<typename Value, typename Parameters = parameters<>, typename Updater = update_store<Value>>
mtl::mat::compressed2D_inserter< Value, Parameters, Updater >::compressed2D_inserter ( matrix_type & m,
size_type slot_size = 5 )
inlineexplicit

Construct inserter for matrix m with slot_size slots per row.

The slots are set up, and the matrix's entries loaded into them, on the first ins[r], not here: an inserter that inserts nothing costs O(1) and leaves the matrix as it was (#855). Before, every inserter paid O(nrows * slot_size + nnz) to build and finalize, so many small inserters on a large matrix were quadratic.

◆ ~compressed2D_inserter()

template<typename Value, typename Parameters = parameters<>, typename Updater = update_store<Value>>
mtl::mat::compressed2D_inserter< Value, Parameters, Updater >::~compressed2D_inserter ( )
inline

◆ compressed2D_inserter() [2/2]

template<typename Value, typename Parameters = parameters<>, typename Updater = update_store<Value>>
mtl::mat::compressed2D_inserter< Value, Parameters, Updater >::compressed2D_inserter ( const compressed2D_inserter< Value, Parameters, Updater > & )
delete

Member Function Documentation

◆ operator=()

template<typename Value, typename Parameters = parameters<>, typename Updater = update_store<Value>>
compressed2D_inserter & mtl::mat::compressed2D_inserter< Value, Parameters, Updater >::operator= ( const compressed2D_inserter< Value, Parameters, Updater > & )
delete

◆ operator[]()

template<typename Value, typename Parameters = parameters<>, typename Updater = update_store<Value>>
row_proxy mtl::mat::compressed2D_inserter< Value, Parameters, Updater >::operator[] ( size_type row)
inline

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