Skip to content

Commit

Permalink
[reductors.residual] fix for riesz calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasbuhr authored and sdrave committed Jan 31, 2019
1 parent f441a79 commit c75eaea
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pymor/reductors/residual.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,15 @@ def apply(self, U, mu=None):
if self.product:
if self.riesz_representatives:
R_riesz = self.product.apply_inverse(R)
return R_riesz * (np.sqrt(R_riesz.dot(R)) / R_riesz.l2_norm())[0]
# divide by norm, except when norm is zero:
inversel2 = 1./R_riesz.l2_norm()
inversel2 = np.nan_to_num(inversel2)
return R_riesz * (np.sqrt(R_riesz.dot(R)) * inversel2)[0]
else:
return R * (np.sqrt(self.product.pairwise_apply2(R, R)) / R.l2_norm())[0]
# divide by norm, except when norm is zero:
inversel2 = 1./R.l2_norm()
inversel2 = np.nan_to_num(inversel2)
return R * (np.sqrt(self.product.pairwise_apply2(R, R)) * inversel2)[0]
else:
return R

Expand Down

0 comments on commit c75eaea

Please sign in to comment.