From 9b11068f0e664d38e5754bbf6f9ff90cf14eb20d Mon Sep 17 00:00:00 2001 From: Johnnie Gray Date: Tue, 23 Jan 2024 19:54:16 -0800 Subject: [PATCH] qr_stabilized: fix rare bug for complex tensors --- docs/changelog.md | 11 +++++++++++ quimb/tensor/decomp.py | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 691e9d0a..5ecee741 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,17 @@ Release notes for `quimb`. +(whats-new-1-7-1)= +## v1.7.1 (unreleased) + +**Bug fixes:** + +- fix bug in [`kruas_op`](quimb.kraus_op) when operator spanned multiple + subsystems ({issue}`214`) +- fix bug in [`qr_stabilized`](quimb.decomp.qr_stabilized) when the diagonal of + `R` has significant imaginary parts. + + (whats-new-1-7-0)= ## v1.7.0 (12-08-2023) diff --git a/quimb/tensor/decomp.py b/quimb/tensor/decomp.py index 52d40666..f6c30b53 100644 --- a/quimb/tensor/decomp.py +++ b/quimb/tensor/decomp.py @@ -616,7 +616,7 @@ def qr_stabilized(x, backend=None): # stabilize the diagonal of R rd = do("diag", R) s = sgn(rd) - Q = rdmul(Q, s) + Q = rdmul(Q, do("conj", s)) R = ldmul(s, R) return Q, None, R @@ -629,7 +629,7 @@ def qr_stabilized_numba(x): rii = R[i, i] si = sgn_numba(rii) if si != 1.0: - Q[:, i] *= si + Q[:, i] *= np.conj(si) R[i, i:] *= si return Q, None, R