Skip to content

Commit

Permalink
Fixes bnorm computation
Browse files Browse the repository at this point in the history
  • Loading branch information
PTNobel committed Dec 29, 2024
1 parent 13f8256 commit bb3bceb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions linops/minres.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def minres(A, b, M=None, x0=None, tol=1e-5, maxiters=None, verbose=True):
assert beta1.min() >= 0, "M must be PD"
if (beta1 == 0).all():
return x
bnorm = torch.linalg.vector_norm(b)
if bnorm == 0:
bnorm = torch.linalg.vector_norm(b, dim=0)
if bnorm.max() == 0:
return b

beta1 = torch.sqrt(beta1) # Supports block
Expand Down Expand Up @@ -143,7 +143,7 @@ def minres(A, b, M=None, x0=None, tol=1e-5, maxiters=None, verbose=True):
rhs2 = - epsilon * z

Anorm = torch.sqrt(tnorm2.max())
ynorm = torch.linalg.norm(x)
ynorm = torch.linalg.norm(x, dim=0)
epsa = Anorm * eps
epsx = Anorm * ynorm * eps
#epsr = Anorm * ynorm * tol
Expand All @@ -152,7 +152,7 @@ def minres(A, b, M=None, x0=None, tol=1e-5, maxiters=None, verbose=True):
diag = epsa
qrnorm = phibar
rnorm = qrnorm
if ynorm == 0 or Anorm == 0:
if ynorm.max() == 0 or Anorm == 0:
test1 = torch.inf
else:
test1 = rnorm / (Anorm * ynorm)
Expand Down

0 comments on commit bb3bceb

Please sign in to comment.