Skip to content
Snippets Groups Projects
Commit 79f489f6 authored by Elias Pipping's avatar Elias Pipping
Browse files

Avoid division by zero

I used nummeric_limits::max() instead of numeric_limits::infinity() here
because the header uses the former to signify an error that cannot lie
below any tolerance elsewhere already.
parent 7b4cf1de
No related branches found
No related tags found
No related merge requests found
...@@ -112,8 +112,9 @@ void ::LoopSolver<VectorType, BitVectorType>::solve() ...@@ -112,8 +112,9 @@ void ::LoopSolver<VectorType, BitVectorType>::solve()
} }
// Turn the error into the relative error, if requested // Turn the error into the relative error, if requested
if (this->useRelativeError_ && !std::isnan(error/oldNorm)) if (this->useRelativeError_ && error != 0)
error = error / oldNorm; error = (oldNorm == 0) ? std::numeric_limits<real_type>::max()
: error / oldNorm;
if (!std::isinf(convRate) && !std::isnan(convRate) && i>0) if (!std::isinf(convRate) && !std::isnan(convRate) && i>0)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment