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.
template<typename Value, typename Parameters = parameters<>, typename Updater = update_store<Value>>
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.