pygsti.tools.matrixtools.induced_projector

pygsti.tools.matrixtools.induced_projector#

induced_projector(mx, tol=1e-12, *, require_real=False)#

Return the orthogonal projector onto range(mx), for mx proportional to a projector.

The input must be Hermitian with exactly two distinct eigenvalue magnitudes, zero and some c > 0 (i.e., mx = c*P for an orthogonal projector P). We eigendecompose mx, rescale so its largest-magnitude eigenvalue is 1, verify that the rescaled spectrum consists of zeros and ones, and rebuild P from the eigenvectors. The result is an exact orthogonal projector up to rounding error, even when mx itself is only approximately proportional to one.

Parameters:
  • mx (numpy array) – The matrix to convert. Must be Hermitian and proportional to an orthogonal projector, up to tol.

  • tol (float, optional) – Tolerance for the Hermiticity, realness, and spectrum checks.

  • require_real (bool, optional) – If True, additionally require that mx is real up to tol.

Returns:

The orthogonal projector onto range(mx).

Return type:

numpy array

Raises:

ValueError – If mx is not real (when require_real is True), not Hermitian, or not proportional to an orthogonal projector.