From d570816c04b6a4b244b722337299370678f92acc Mon Sep 17 00:00:00 2001 From: Brandon Talamini Date: Tue, 26 Jul 2022 22:06:52 -0700 Subject: [PATCH] Avoid superfluous copy of residual vector when applying preconditioner The residual vector is changed from a jax-numpy array to a standard numpy array before the preconditioner is applied. Now numpy is told to avoid copying the residual data and instead re-use the buffer. This should avoid overhead, especially for large vectors. --- optimism/SparseCholesky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimism/SparseCholesky.py b/optimism/SparseCholesky.py index ee6f64c6..e6e43584 100644 --- a/optimism/SparseCholesky.py +++ b/optimism/SparseCholesky.py @@ -51,7 +51,7 @@ def update(self, new_stiffness_func): def apply(self, b): if type(b) == type(np.array([])): - b = onp.array(b) + b = onp.array(b, copy=False) return self.Precond(b)