sandialabs / pyGSTi

A python implementation of Gate Set Tomography
http://www.pygsti.info
Apache License 2.0
132 stars 55 forks source link

Fixes bug in DenseOperator.kraus_operators when Choi matrix has degen… #423

Closed enielse closed 2 months ago

enielse commented 2 months ago

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).