The code is actually correct, you just have the wrong field
The result of eigenvalues ββis valid for unitary matrices (complex records); based on the code from section 4.6 of the Edelman and Rao document, if you replace the first line with
X = randn(dim, dim) + im*randn(dim, dim)
You will get the desired result.
Orthogonal matrices (real records) behave somewhat differently (see note 1, section 3 of this document ):
- when
dims is odd, one eigenvalue will be +1 or -1 (each with a probability of 1/2), all others will occur as conjugate pairs. - when
dims even, both +1 and -1 will be eigenvalues ββwith a probability of 1/2, otherwise there are no real eigenvalues.
(Thanks for the links, by the way: I did not know about Stuart's paper)
source share