qit.utils.rand_positive

qit.utils.rand_positive(n)

Random n*n positive semidefinite matrix.

Parameters

n (int) – matrix size

Returns

random positive semidefinite matrix with trace 1

Return type

array[complex]

Since the returned matrix has all-real eigenvalues, it is Hermitian by construction.