add indexed iterator ranges
currently we can not use ranged-based for in dune-istl, because many algorithms have to know the index of an entry in the sparse matrix. This index is not the same as the std::distance(begin,it)
and can not be computed using standard iterators.
I suggest to add a wrapper type, with the following interface:
template<typename T>
struct IndexedValue {
std::size_t index() const;
T & value();
const T & value() const;
};
This will allow us to implement a special index_range(Matrix)
or index_range(Vector)
which yields IndexedValue
instead of the value directly.
These new ranges and new types can be implemented completely outside the current istl containers.
The BCRSMatrix::umv
might now look like:
void umv (const X& x, Y& y) const
{
for (const auto & row : indexed_range(*this))
for (const auto & entry : indexed_range(row.value()))
entry.value().umv(x[entry.index()],y[row.index()]);
}
instead of
void umv (const X& x, Y& y) const
{
ConstRowIterator endi=end();
for (ConstRowIterator i=begin(); i!=endi; ++i)
{
ConstColIterator endj = (*i).end();
for (ConstColIterator j=(*i).begin(); j!=endj; ++j)
(*j).umv(x[j.index()],y[i.index()]);
}
}