45#ifndef __ADS_DynamicCsr
46 #define __ADS_DynamicCsr
78template<
class I =
int ,
class V =
double >
82 static_assert( std::is_integral_v< I > );
93 [[nodiscard]] std::size_t
rows(
void )
const {
return( f_beg.size() - 1 ); }
96 [[nodiscard]] std::size_t
nonzeros(
void )
const {
return( f_ind.size() ); }
99 [[nodiscard]]
bool empty(
void )
const {
return(
rows() == 0 ); }
102 void reserve( std::size_t r , std::size_t z );
122 std::size_t
append( std::span< const I >
ind , std::span< const V >
val );
171 template< std::ranges::contiguous_range R >
178 void remove( std::size_t first , std::size_t last );
182 [[nodiscard]] std::span< const I >
indices( std::size_t i )
const;
186 [[nodiscard]] std::span< const V >
values( std::size_t i )
const;
190 [[nodiscard]] std::span< V >
values( std::size_t i );
194 [[nodiscard]]
const I *
beg(
void )
const {
return( f_beg.data() ); }
197 [[nodiscard]]
const I *
ind(
void )
const {
return( f_ind.data() ); }
200 [[nodiscard]]
const V *
val(
void )
const {
return( f_val.data() ); }
205 using Vector = std::vector< U , detail::DefaultInitAllocator< U > >;
208 [[nodiscard]]
bool consistent(
void )
const;
217template<
class I =
int ,
class V =
double >
228#include "ADS/numeric/impl/DynamicCsr.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The dense matrices by rows, beyond the book: DenseMatrix keeps the entries by rows in one contiguous...
a sparse matrix by rows, with indices of type I and values of type V, whose rows are appended and rem...
Definition DynamicCsr.h:80
void clear(void)
removes all the rows, keeping the memory
bool empty(void) const
true if the matrix has no row
Definition DynamicCsr.h:99
std::size_t append(std::size_t r, const I *beg, const I *ind, const V *val)
appends the rows of a compressed form: the row has the entries to of ind and val; the index of th...
DynamicCsr(void)
the matrix of no rows
Definition DynamicCsr.h:90
std::size_t nonzeros(void) const
the number of the entries
Definition DynamicCsr.h:96
std::span< const I > indices(std::size_t i) const
the minor indices of the row
std::size_t rows(void) const
the number of the rows
Definition DynamicCsr.h:93
void remove(std::size_t first, std::size_t last)
removes the rows from to , excluded, by one erase of their entries and a shift of the starts after ...
std::size_t append(std::span< const I > ind, std::span< const V > val)
appends the row of the entries ; its index
std::span< V > values(std::size_t i)
the values of the row , to change in place
const I * beg(void) const
Definition DynamicCsr.h:194
void reserve(std::size_t r, std::size_t z)
room for rows and entries
V Value
the type of the values
Definition DynamicCsr.h:87
std::span< const V > values(std::size_t i) const
the values of the row
void remove(const R &E)
removes the rows of (a contiguous range of integers, e.g., a std::vector), closing the gaps in one p...
const V * val(void) const
Definition DynamicCsr.h:200
const I * ind(void) const
Definition DynamicCsr.h:197
I Index
the type of the indices
Definition DynamicCsr.h:86
DynamicCsr< I, V > DynamicCsc
the same by columns
Definition DynamicCsr.h:218