Draft: Provide hybrid range and size utilities for matrices and vectors
Summary
This MR extends the idea of hybrid size from dune-common to matrices and vectors. It provides free functions Hybrid::numRows
, Hybrid::numCols
and Hybrid::numEntries
for number of rows and number of columns of matrices, as well as number of entries in a vector, respectively. Thereby the specialization is done with dynamic-first idea. If a container provides dynamic index access, the corresponding size functions return a std::size_t
. Otherwise if element access is not dynamic and size is a static constant, the methods provide size information as std::integral_constant
. This allows to iterate over the containers using Hybrid::forEach
where again, dynamic iteration is preferred over static (unrolled/recursive) iteration.
Discussion
- The dynamic-first principle is used here for (typically) faster compile-times and better readable error messages. For vectors you have in dune-common also a static-first principle implemented in
Dune::Hybrid::size
. - I'm not yet sure about the naming of the functions. I have to distinguish
numEntries
fromsize
for vectors.