Skip to content
Snippets Groups Projects
Commit 67169205 authored by Oliver Sander's avatar Oliver Sander
Browse files

[MultiTypeBlockMatrix] implement infinity_norm

And test it.
parent e7a13bd9
Branches
Tags
1 merge request!282Improve matrix testing
Pipeline #17468 failed
......@@ -356,6 +356,49 @@ namespace Dune {
{
return sqrt(frobenius_norm2());
}
//! Bastardized version of the infinity-norm / row-sum norm
auto infinity_norm () const
{
using field_type = typename std::decay_t<decltype((*this)[Indices::_0][Indices::_0])>::field_type;
using std::max;
typename FieldTraits<field_type>::real_type norm=0;
auto rows = index_constant<N()>();
Hybrid::forEach(Hybrid::integralRange(rows), [&](auto&& i) {
typename FieldTraits<field_type>::real_type sum=0;
auto cols = index_constant<M()>();
Hybrid::forEach(Hybrid::integralRange(cols), [&](auto&& j) {
sum += (*this)[i][j].infinity_norm();
});
norm = max(sum, norm);
});
return norm;
}
//! Bastardized version of the infinity-norm / row-sum norm
auto infinity_norm_real () const
{
using field_type = typename std::decay_t<decltype((*this)[Indices::_0][Indices::_0])>::field_type;
using std::max;
typename FieldTraits<field_type>::real_type norm=0;
auto rows = index_constant<N()>();
Hybrid::forEach(Hybrid::integralRange(rows), [&](auto&& i) {
typename FieldTraits<field_type>::real_type sum=0;
auto cols = index_constant<M()>();
Hybrid::forEach(Hybrid::integralRange(cols), [&](auto&& j) {
sum += (*this)[i][j].infinity_norm_real();
});
norm = max(sum, norm);
});
return norm;
}
};
/**
......
......@@ -71,6 +71,9 @@ void testInterfaceMethods()
// Test vector space operations
testVectorSpaceOperations(multiMatrix);
// Test matrix norms
testNorms(multiMatrix);
// Test whether matrix class has the required constructors
testMatrixConstructibility<decltype(multiMatrix)>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment