ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
DynamicCsr.h File Reference

A compressed sparse matrix that grows and shrinks by whole rows (or whole columns), beyond the book: the bundle of the cuts of a decomposition, whose rows come in batches and go away in batches, kept at all times in the arrays \( \mathit{beg} \), \( \mathit{ind} \) and \( \mathit{val} \) that the solvers of linear programs take, so that handing it over costs nothing. More...

#include "ADS/Contract.h"
#include "ADS/numeric/DenseMatrix.h"
#include <algorithm>
#include <cstddef>
#include <limits>
#include <ranges>
#include <span>
#include <type_traits>
#include <utility>
#include <vector>
#include "ADS/numeric/impl/DynamicCsr.tpp"

Go to the source code of this file.

Classes

class  ADS::DynamicCsr< I, V >
 a sparse matrix by rows, with indices of type I and values of type V, whose rows are appended and removed More...

Namespaces

namespace  ADS

Typedefs

template<class I = int, class V = double>
using ADS::DynamicCsc = DynamicCsr< I , V >
 the same by columns

Detailed description

A compressed sparse matrix that grows and shrinks by whole rows (or whole columns), beyond the book: the bundle of the cuts of a decomposition, whose rows come in batches and go away in batches, kept at all times in the arrays \( \mathit{beg} \), \( \mathit{ind} \) and \( \mathit{val} \) that the solvers of linear programs take, so that handing it over costs nothing.

The matrix is three vectors: \( \mathit{beg} \), with one entry more than the rows, \( \mathit{beg}[ i ] \) the first entry of the row \( i \) and its last entry the number of the entries, and \( \mathit{ind} \) and \( \mathit{val} \), the minor index and the value of each entry, the rows one after the other. append() adds a row at the end in time linear in its entries, amortized over the doubling of the vectors; remove() takes a strictly increasing set of rows and closes the gaps in one pass, moving each entry after the first row removed once, in \( O( r + z' ) \) time for \( r \) rows and \( z' \) entries after the first row removed, with no scratch memory. The same type is the compressed sparse columns, DynamicCsc, when the major index is a column.

The contracts [see Contract.h]: a row has as many indices as values, the number of the entries fits the index type I, the rows removed are strictly increasing and below the number of the rows; the invariant is that \( \mathit{beg} \) starts at 0, never decreases and ends at the number of the entries. The operations are defined in DynamicCsr.tpp.

See also
F. G. Gustavson, Two fast algorithms for sparse matrices: multiplication and permuted transposition, ACM Transactions on Mathematical Software 4(3), 250-269, 1978, doi:10.1145/355791.355796 (the compressed sparse rows)
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa