I have a very simple question. Suppose I have a Hermitian matrix A and I want to calculate its eigenvectors. I can use eigvecs(A) and the columns of it are the eigenvectors. But I want to know what is the order of these eigenvectors. Suppose I want to ask them to order based on the eigenvalues. The eigenvector corresponding to the smallest eigenvalue is the leftmost column and the eigenvector corresponding to the largest eigenvalue is the rightmost column. What should I do?
This comes from the documentation of eigen, which the documentation of eigvecs redirected me to:
By default, the eigenvalues and vectors are sorted lexicographically by (real(λ),imag(λ)).
A different comparison function by(λ) can be passed to sortby, or you can pass sortby=nothing to leave the eigenvalues in an arbitrary order.
Some special matrix types (e.g. Diagonal or SymTridiagonal) may implement their own sorting convention and not accept a sortby keyword.