Skip to content

Commit

Permalink
Applying a slight perturbation for ill-conditioned matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderivrii committed Feb 19, 2025
1 parent 2b56910 commit 0aacbf5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions qiskit/quantum_info/operators/channel/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ def _choi_to_kraus(data, input_dim, output_dim, atol=ATOL_DEFAULT):
#
# So the eigenvalues are on the diagonal, therefore the basis-transformation matrix must be
# a spanning set of the eigenspace.

if np.linalg.cond(data) >= 1e10:
# Regularization: applying a small perturbation for ill-conditioned matrices.
data += 1e-10 * np.eye(data.shape[0])

triangular, vecs = scipy.linalg.schur(data)
values = triangular.diagonal().real
# If we're not a CP map, fall-through back to the generalization handling. Since we needed
Expand Down

0 comments on commit 0aacbf5

Please sign in to comment.