Skip to content
Snippets Groups Projects
Commit d34a21fe authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de
Browse files

Implement addToDiagonal for scalars (interpreted as 1x1 matrices)

This is required for dune-istl matrices than use scalars to end
the nesting recursion (and not FieldMatrix), like BCRSMatrix<double>.
parent 009c7743
No related branches found
No related tags found
1 merge request!12Implement addToDiagonal for scalars (interpreted as 1x1 matrices)
# 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
......
......@@ -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
......
......@@ -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}},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment