Skip to content
Snippets Groups Projects
Commit 36f6cfbc authored by Ansgar Burchardt's avatar Ansgar Burchardt
Browse files

Merge branch 'h1seminorm-smart-pointer' into 'master'

H1SemiNorm: use smart pointer for matrix

See merge request !35
parents 9a516165 2919173a
No related branches found
No related tags found
1 merge request!35H1SemiNorm: use smart pointer for matrix
Pipeline #17318 passed
......@@ -8,6 +8,7 @@
#include <dune/common/fmatrix.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/solvers/common/wrapownshare.hh>
#include "norm.hh"
//! Specialisation of the EnergyNorm class to identity blocks
......@@ -23,12 +24,13 @@ public:
/** \brief The type used for the result */
using typename Base::field_type;
H1SemiNorm() : matrix_(NULL) {}
H1SemiNorm() = default;
H1SemiNorm(const MatrixType& matrix)
: matrix_(&matrix)
template<typename Matrix>
H1SemiNorm(Matrix&& matrix)
: matrix_(Dune::Solvers::wrap_own_share<const MatrixType>(std::forward<Matrix>(matrix)))
{
assert(matrix.N() == matrix.M());
assert(matrix_->N() == matrix_->M());
}
//! Compute the norm of the difference of two vectors
......@@ -77,7 +79,7 @@ public:
return std::sqrt(sum);
}
const MatrixType* matrix_;
std::shared_ptr<const MatrixType> matrix_;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment