Template Class DynamicCsr

Class Documentation

template<class I = int, class V = double>
class DynamicCsr

a sparse matrix by rows, with indices of type I and values of type V, whose rows are appended and removed

Public Types

using Index = I

the type of the indices

using Value = V

the type of the values

Public Functions

inline DynamicCsr(void)

the matrix of no rows

inline std::size_t rows(void) const

the number of the rows

inline std::size_t nonzeros(void) const

the number of the entries

inline bool empty(void) const
void reserve(std::size_t r, std::size_t z)

room for r rows and z entries

void clear(void)

removes all the rows, keeping the memory

std::size_t append(std::span<const I> ind, std::span<const V> val)

appends the row of the entries ( ind[ k ] , val[ k ] ); its index

Pre:

ind and val have the same length

std::size_t append(std::size_t r, const I *beg, const I *ind, const V *val)

appends the r rows of a compressed form: the row k has the entries beg[ k ] - beg[ 0 ] to beg[ k + 1 ] - beg[ 0 ] of ind and val; the index of the first one

Pre:

beg is not decreasing

template<std::ranges::contiguous_range R>
void remove(const R &E)

removes the rows of E (a contiguous range of integers, e.g., a std::vector), closing the gaps in one pass

Pre:

E is strictly increasing and below rows()

void remove(std::size_t first, std::size_t last)

removes the rows from first to last, last excluded

Pre:

first <= last <= rows()

std::span<const I> indices(std::size_t i) const

the minor indices of the row i

Pre:

i < rows()

std::span<const V> values(std::size_t i) const

the values of the row i

Pre:

i < rows()

std::span<V> values(std::size_t i)

the values of the row i, to change in place

Pre:

i < rows()

inline const I *beg(void) const

the rows() + 1 starts of the rows, the last one the number of the entries

inline const I *ind(void) const

the minor index of each entry

inline const V *val(void) const

the value of each entry