Skip to content

Commit 0aacbf5

Browse files
Applying a slight perturbation for ill-conditioned matrices
1 parent 2b56910 commit 0aacbf5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

qiskit/quantum_info/operators/channel/transformations.py

+5
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ def _choi_to_kraus(data, input_dim, output_dim, atol=ATOL_DEFAULT):
234234
#
235235
# So the eigenvalues are on the diagonal, therefore the basis-transformation matrix must be
236236
# a spanning set of the eigenspace.
237+
238+
if np.linalg.cond(data) >= 1e10:
239+
# Regularization: applying a small perturbation for ill-conditioned matrices.
240+
data += 1e-10 * np.eye(data.shape[0])
241+
237242
triangular, vecs = scipy.linalg.schur(data)
238243
values = triangular.diagonal().real
239244
# If we're not a CP map, fall-through back to the generalization handling. Since we needed

0 commit comments

Comments
 (0)