pygsti.tools.optools.fast_density_rank

pygsti.tools.optools.fast_density_rank#

fast_density_rank(mat, scalar_tol=None, rng=0)#

mat is Hermitian of order n. This function uses an O(n^2) time randomized algorithm to test if mat is a PSD matrix of rank 0 or 1. It returns a tuple (r, vec), where

r == 0 means mat’s numerical rank is zero OR its projection onto the set of PSD matrices is zero. The value of vec should be ignored.

r == 1 means mat is numerically equal to _np.outer(vec, vec.conj()), where vec is nonzero.

r == 2 means mat’s numerical rank is at least two, but we know nothing beyond that. The value of vec should be ignored.

r == -1 means mat’s numerical rank is at least one, but we know nothing beyond that. The value of vec should be ignored.

Conceptually, this function just takes a single step of the power iteration method for estimating mat’s largest eigenvalue (with size measured in absolute value). See https://en.wikipedia.org/wiki/Power_iteration for more information.

Parameters:
  • mat (ndarray)

  • scalar_tol (float | floating | None)

  • rng (None | int | Generator)

Return type:

tuple[int, ndarray]