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

Make sure infinity_norm returns NaN if a DenseVector contains NaN exclusively

Patch by Elias Pipping, thanks.

FS 1147

[[Imported from SVN: r6914]]
parent 07acc74a
No related branches found
No related tags found
No related merge requests found
......@@ -531,19 +531,29 @@ namespace Dune {
//! infinity norm (maximum of absolute values of entries)
typename FieldTraits<value_type>::real_type infinity_norm () const
{
typename FieldTraits<value_type>::real_type result( 0 );
for (size_type i=0; i<size(); i++)
result = std::max(result, std::abs((*this)[i]));
return result;
if (size() == 0)
return 0.0;
ConstIterator it = begin();
typename FieldTraits<value_type>::real_type max = std::abs(*it);
for (it = it + 1; it != end(); ++it)
max = std::max(max, std::abs(*it));
return max;
}
//! simplified infinity norm (uses Manhattan norm for complex values)
typename FieldTraits<value_type>::real_type infinity_norm_real () const
{
typename FieldTraits<value_type>::real_type result( 0 );
for (size_type i=0; i<size(); i++)
result = std::max(result, fvmeta::absreal((*this)[i]));
return result;
if (size() == 0)
return 0.0;
ConstIterator it = begin();
typename FieldTraits<value_type>::real_type max = fvmeta::absreal(*it);
for (it = it + 1; it != end(); ++it)
max = std::max(max, fvmeta::absreal(*it));
return max;
}
//===== sizes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment