Skip to content

Commit

Permalink
Merge pull request #157 from mrava87/patch-affine
Browse files Browse the repository at this point in the history
fix: use cg instead of lsqr in AffineSet
  • Loading branch information
mrava87 authored Jan 17, 2024
2 parents b19399c + 3147167 commit 0e8caf7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 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
2 changes: 1 addition & 1 deletion pyproximal/projection/Hankel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from scipy.linalg import hankel


class HankelProj:
class HankelProj():
r"""Hankel matrix projection.
Solves the least squares problem
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pytest
pytest-runner
setuptools_scm
docutils<0.18
Sphinx==4.2.0
Sphinx
sphinx-gallery
pydata-sphinx-theme
numpydoc
Expand Down

0 comments on commit 0e8caf7

Please sign in to comment.