Skip to content

Commit dd404e6

Browse files
committed
minor: restore some behaviors for preallocate=False
1 parent a35540b commit dd404e6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

pylops/optimization/cls_basic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def setup(
151151
x = self.ncp.zeros(self.Op.shape[1], dtype=self.y.dtype)
152152
self.r = self.y.copy()
153153
else:
154-
x = x0
154+
x = x0.copy()
155155
if not self.preallocate:
156156
self.r = self.y - self.Op.matvec(x)
157157
else:
@@ -518,7 +518,7 @@ def step(self, x: NDArray, show: bool = False) -> NDArray:
518518
self.q.dot(self.q.conj()) + self.damp * self.c.dot(self.c.conj())
519519
)
520520
if not self.preallocate:
521-
x += a * self.c
521+
x = x + a * self.c
522522
self.s = self.s - a * self.q
523523
r = self.Op.rmatvec(self.s) - self.damp * x
524524
else:
@@ -950,8 +950,8 @@ def setup(
950950
self.arnorm: float = self.alfa * self.beta
951951

952952
# initialize other internal variables
953-
self.dk = self.ncp.empty_like(self.w)
954953
if self.preallocate:
954+
self.dk = self.ncp.empty_like(self.w)
955955
self.w1 = self.ncp.empty_like(self.w)
956956

957957
# finalize setup

0 commit comments

Comments
 (0)