Eigen values and vectors sorting

To get the eigenvalues in the same order as in matlab, take
eigen_vals[end:-1:1], and eigen_vector[:, end:-1:1]. You cannot predict the sign of a column, because if v is an eigenvector corresponding to the eigenvalue \lambda, then Av=\lambda v. But to an eigenvalue does not correspond a single vector, but a subspace. Together with v, \alpha v (\alpha a scalar) is also an eigenvector corresponding to \lambda. Hence for both \alpha=1 and \alpha=-1 you get an eigenvector for the same eigenvalue.

1 Like