From 5289423b8189bfa721e5433bc64913296879a67d Mon Sep 17 00:00:00 2001 From: Max Kahnt <max.kahnt@fu-berlin.de> Date: Fri, 19 May 2017 10:40:19 +0200 Subject: [PATCH] Use sparseRangeFor instead of rangeForEach for consistency. It still is in dune-solvers and provides the very same functionality. --- dune/matrix-vector/algorithm.hh | 4 ++-- dune/matrix-vector/axpy.hh | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dune/matrix-vector/algorithm.hh b/dune/matrix-vector/algorithm.hh index 30d2cf0..5f618a1 100644 --- a/dune/matrix-vector/algorithm.hh +++ b/dune/matrix-vector/algorithm.hh @@ -16,7 +16,7 @@ namespace MatrixVector { */ template <class Range, class F, typename = std::enable_if_t<Dune::IsTupleOrDerived<Range>::value>> -void rangeForEach(const Range& range, F&& f) { +void sparseRangeFor(const Range& range, F&& f) { using namespace Dune::Hybrid; forEach(integralRange(size(range)), [&](auto&& i) { f(range[i], i); }); } @@ -25,7 +25,7 @@ void rangeForEach(const Range& range, F&& f) { * \brief Hybrid for loop over sparse range */ template<class Range, class F> -void rangeForEach(Range&& range, F&& f) +void sparseRangeFor(Range&& range, F&& f) { for (auto it = range.begin(); it != range.end(); ++it) f(*it, it.index()); diff --git a/dune/matrix-vector/axpy.hh b/dune/matrix-vector/axpy.hh index 72442be..fe6740f 100644 --- a/dune/matrix-vector/axpy.hh +++ b/dune/matrix-vector/axpy.hh @@ -115,9 +115,9 @@ namespace MatrixVector { class ADummy = A, std::enable_if_t<MatrixTraits<ADummy>::isMatrix, int> SFINAE_Dummy = 0> static void addProduct(A& a, const B& b, const C& c) { - rangeForEach(b, [&](auto&& bi, auto&& i) { - rangeForEach(bi, [&](auto&& bik, auto&& k) { - rangeForEach(c[k], [&](auto&& ckj, auto&& j) { + sparseRangeFor(b, [&](auto&& bi, auto&& i) { + sparseRangeFor(bi, [&](auto&& bik, auto&& k) { + sparseRangeFor(c[k], [&](auto&& ckj, auto&& j) { Dune::MatrixVector::addProduct(a[i][j], bik, ckj); }); }); @@ -141,9 +141,9 @@ namespace MatrixVector { class ADummy = A, std::enable_if_t<MatrixTraits<ADummy>::isMatrix, int> SFINAE_Dummy = 0> static void addProduct(A& a, const Scalar& scalar, const B& b, const C& c) { - rangeForEach(b, [&](auto&& bi, auto&& i) { - rangeForEach(bi, [&](auto&& bik, auto&& k) { - rangeForEach(c[k], [&](auto&& ckj, auto&& j) { + sparseRangeFor(b, [&](auto&& bi, auto&& i) { + sparseRangeFor(bi, [&](auto&& bik, auto&& k) { + sparseRangeFor(c[k], [&](auto&& ckj, auto&& j) { Dune::MatrixVector::addProduct(a[i][j], scalar, bik, ckj); }); }); @@ -328,8 +328,8 @@ namespace MatrixVector { class ADummy = A, std::enable_if_t<MatrixTraits<ADummy>::isMatrix, int> SFINAE_Dummy = 0> static void addProduct(A& a, const B& b, const C& c) { - rangeForEach(c, [&](auto&& ci, auto && i) { - rangeForEach(ci, [&](auto&& cij, auto && j) { + sparseRangeFor(c, [&](auto&& ci, auto && i) { + sparseRangeFor(ci, [&](auto&& cij, auto && j) { Dune::MatrixVector::addProduct(a[i][j], b, cij); }); }); @@ -353,8 +353,8 @@ namespace MatrixVector { class ADummy = A, std::enable_if_t<MatrixTraits<ADummy>::isMatrix, int> SFINAE_Dummy = 0> static void addProduct(A& a, const Scalar& scalar, const B& b, const C& c) { - rangeForEach(c, [&](auto&& ci, auto&& i) { - rangeForEach(ci, [&](auto&& cij, auto&& j) { + sparseRangeFor(c, [&](auto&& ci, auto&& i) { + sparseRangeFor(ci, [&](auto&& cij, auto&& j) { Dune::MatrixVector::addProduct(a[i][j], scalar, b, cij); }); }); -- GitLab