Fixes a bug in DenseOperator.kraus_operators when Choi matrix has degenerate spectrum.
Switches a numpy.linalg.eig call to numpy.linalg.eigh to ensure that the matrix of eigenvectors is unitary. This is not always the case for eig (in particular for matrices with degenerate spectra), and is assumed by the code in kraus_operators. The eig routine has had a history of not always giving a correct diagonalization, and so this PR also adds an assertion to ensure this is the case.
Also adds a unit test that verifies Kraus decomposition works as expected for a depolarizing channel (one example of a channel with a degenerate Choi matrix spectrum).
Fixes a bug in
DenseOperator.kraus_operators
when Choi matrix has degenerate spectrum.Switches a
numpy.linalg.eig
call tonumpy.linalg.eigh
to ensure that the matrix of eigenvectors is unitary. This is not always the case foreig
(in particular for matrices with degenerate spectra), and is assumed by the code inkraus_operators
. Theeig
routine has had a history of not always giving a correct diagonalization, and so this PR also adds an assertion to ensure this is the case.Also adds a unit test that verifies Kraus decomposition works as expected for a depolarizing channel (one example of a channel with a degenerate Choi matrix spectrum).