diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a2decd792acfad9c19a54bac15a22d62163515ef..64a3fecd122c9a791519086241ca5711d0909dc1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,6 @@ dune:git gcc-8 C++17: image: registry.dune-project.org/docker/ci/dune:git-debian-10-gcc-8-17 script: duneci-standard-test -dune:git gcc-6 C++14: - image: registry.dune-project.org/docker/ci/dune:git-debian-9-gcc-6-14 +dune:git gcc-9 C++20: + image: registry.dune-project.org/docker/ci/dune:git-debian-11-gcc-9-20 script: duneci-standard-test diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a5d1c7066fcdd55447d17a9fe00bbe3944154d4..c766858dd10c55e8f05f55644c064e4bef54e103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Master (will become release 2.8) -- ... +- The method `addToDiagonal` can now also be called if the matrix is a scalar number type. + This is needed since nowadays scalar entries can end the nesting recursion of dune-istl + matrices. ## Deprecations and removals diff --git a/dune/matrix-vector/addtodiagonal.hh b/dune/matrix-vector/addtodiagonal.hh index 90ad152bb9041c0941a5638051ecbd743418b192..56de2fae4d5ec3d76c365882864a29395f8ef92b 100644 --- a/dune/matrix-vector/addtodiagonal.hh +++ b/dune/matrix-vector/addtodiagonal.hh @@ -11,6 +11,14 @@ namespace MatrixVector { x[i][i] += a; } + /** \brief Specialization for scalars (to be interpreted as 1x1 matrices) */ + template <class Matrix> + static void addToDiagonal(Matrix& x, const Matrix& a) + { + static_assert(IsNumber<Matrix>::value, "Only scalars can be treated both as matrix and as number!"); + x += a; + } + /* the line diff --git a/dune/matrix-vector/test/resizetest.cc b/dune/matrix-vector/test/resizetest.cc index bdb6923b1d7a5a7bf455c74cfe611894867a914d..a9ff7879a311832685cc2cb359ebee0c68aef6b1 100644 --- a/dune/matrix-vector/test/resizetest.cc +++ b/dune/matrix-vector/test/resizetest.cc @@ -77,7 +77,7 @@ bool checkResize() { FV fv; resize(fv, Dune::FieldVector<int, 5>()); return false; - } catch (Dune::Exception) { + } catch (Dune::Exception&) { // TODO make sure the right exception is thrown } @@ -116,9 +116,9 @@ bool checkResize() { // test "unnatural" matrix types // TODO - } catch (Dune::Exception e) { + } catch (Dune::Exception& e) { std::cout << "FAILURE." << std::endl; - std::cout << e << std::endl; + std::cout << e.what() << std::endl; return false; } diff --git a/dune/matrix-vector/test/staticmatrixtoolstest.cc b/dune/matrix-vector/test/staticmatrixtoolstest.cc index 368f523445f45f9a1b3f9baca94d29252c7fc7f4..b3566a525364a1c89b701afb080133b3bb8cc232 100644 --- a/dune/matrix-vector/test/staticmatrixtoolstest.cc +++ b/dune/matrix-vector/test/staticmatrixtoolstest.cc @@ -35,6 +35,16 @@ private: // SQUARE MATRICES + // scalars + { + FieldType scalarMatrix_x = 1, + scalarMatrix_check = 4; + + addToDiagonal(scalarMatrix_x, scalar_a); + + passed = passed and + myDiff(scalarMatrix_x, scalarMatrix_check) < 1e-12; + } // case FM { Dune::FieldMatrix<FieldType, 2, 2> squareFieldMatrix_x = {{1, 2}, {3, 4}}, diff --git a/dune/matrix-vector/triangularsolve.hh b/dune/matrix-vector/triangularsolve.hh index 4d7c42e8a42969ddfb86e9e82ab6928c87473a86..5d21f49693648f9faeb09076517b7ae6fb7c097c 100644 --- a/dune/matrix-vector/triangularsolve.hh +++ b/dune/matrix-vector/triangularsolve.hh @@ -37,7 +37,7 @@ namespace MatrixVector { // Note: We could drop the check for ignore nodes here bcs. b[j] will // be ignored anyway due to the check above. if (ignore == nullptr or (*ignore)[j].none()) - b[j] -= x[i] * *cIt; + cIt->mmv(x[i], b[j]); } } } else {