Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove problematic array copy operations #156

Merged
merged 2 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scico/optimize/_ladmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def z_init(self, x0: Union[JaxArray, BlockArray]):
x0: Starting point for :math:`\mb{x}`.
"""
z = self.C(x0)
z_old = z.copy()
z_old = z
return z, z_old

def u_init(self, x0: Union[JaxArray, BlockArray]):
Expand Down Expand Up @@ -297,7 +297,7 @@ def step(self):
proxarg = self.x - (self.mu / self.nu) * self.C.conj().T(self.C(self.x) - self.z + self.u)
self.x = self.f.prox(proxarg, self.mu, v0=self.x)

self.z_old = self.z.copy()
self.z_old = self.z
Cx = self.C(self.x)
self.z = self.g.prox(Cx + self.u, self.nu, v0=self.z)
self.u = self.u + Cx - self.z
Expand Down
8 changes: 4 additions & 4 deletions scico/optimize/_primaldual.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ def __init__(
dtype = C.input_dtype
x0 = snp.zeros(input_shape, dtype=dtype)
self.x = ensure_on_device(x0)
self.x_old = self.x.copy()
self.x_old = self.x
if z0 is None:
input_shape = C.output_shape
dtype = C.output_dtype
z0 = snp.zeros(input_shape, dtype=dtype)
self.z = ensure_on_device(z0)
self.z_old = self.z.copy()
self.z_old = self.z

def objective(
self,
Expand Down Expand Up @@ -232,8 +232,8 @@ def norm_dual_residual(self) -> float:

def step(self):
"""Perform a single iteration."""
self.x_old = self.x.copy()
self.z_old = self.z.copy()
self.x_old = self.x
self.z_old = self.z
proxarg = self.x - self.tau * self.C.conj().T(self.z)
self.x = self.f.prox(proxarg, self.tau, v0=self.x)
proxarg = self.z + self.sigma * self.C(
Expand Down