Skip to content

Commit

Permalink
fix: use cg instead of lsqr in AffineSet
Browse files Browse the repository at this point in the history
  • Loading branch information
mrava87 committed Jan 17, 2024
1 parent b19399c commit d04409d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pyproximal/projection/AffineSet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from scipy.sparse.linalg import lsqr as sp_lsqr
from pylops.optimization.basic import lsqr
from scipy.sparse.linalg import cg as sp_cg
from pylops.optimization.basic import cg, lsqr
from pylops.utils.backend import get_array_module, get_module_name


Expand Down Expand Up @@ -41,8 +42,8 @@ def __init__(self, Op, b, niter):

def __call__(self, x):
if get_module_name(get_array_module(x)) == 'numpy':
inv = sp_lsqr(self.Op * self.Op.H, self.Op * x - self.b, iter_lim=self.niter)[0]
inv = sp_cg(self.Op * self.Op.H, self.Op * x - self.b, maxiter=self.niter)[0]
else:
inv = lsqr(self.Op * self.Op.H, self.Op * x - self.b, niter=self.niter)[0]
inv = cg(self.Op * self.Op.H, self.Op * x - self.b, niter=self.niter)[0]
y = x - self.Op.H * inv.ravel() # currently ravel is added to ensure that the output is always a vector
return y

0 comments on commit d04409d

Please sign in to comment.