Issue
I have compute a very large matrix M with lots of degenerate eigenvectors(different eigenvectors with same eigenvalues). I use QR decomposition to make sure these eigenvectors are orthonormal, so the Q is the orthonormal eigenvectors of M, and Q^{-1}MQ = D, where D is diagonal matrix. Now I want to check if D is truly diagonal matrix, but when I print D, the matrix is too large to show all of them, so how can I know if it is truly diagonal matrix?
Solution
Remove the diagonal and count the non zero elements:
np.count_nonzero(x - np.diag(np.diagonal(x)))
Answered By - donkopotamus
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.