I'm using the Armadillo Cpp code for matrix algebra. I have an Eigenvector matrix E
that I want to sort by its eigenvalues in a vector d
.
mat E;
vec d;
eig_sym(d,E,Rxx);
// Sort indices of eignen values / vectors
// based on decreasing real part of eigen values.
uvec order = sort_index(-d);
// Extract top eigen vectors.
E = E(span::all,order(1,nb_sources));
I couldn't find anything related to this kind of indexing in the documentation. Indexing using a vector is such a common requirement that I'd be surprised if it isn't present in Armadillo.
What is the proper way to do this in Armadillo?