Mercurial > hg > camir-aes2014
diff toolboxes/FullBNT-1.0.7/KPMtools/sort_evec.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolboxes/FullBNT-1.0.7/KPMtools/sort_evec.m Tue Feb 10 15:05:51 2015 +0000 @@ -0,0 +1,22 @@ +function [evec, evals] = sort_evec(temp_evec, temp_evals, N) + +if ~isvectorBNT(temp_evals) + temp_evals = diag(temp_evals); +end + +% Eigenvalues nearly always returned in descending order, but just +% to make sure..... +[evals perm] = sort(-temp_evals); +evals = -evals(1:N); +if evals == temp_evals(1:N) + % Originals were in order + evec = temp_evec(:, 1:N); + return +else + fprintf('sorting evec\n'); + % Need to reorder the eigenvectors + for i=1:N + evec(:,i) = temp_evec(:,perm(i)); + end +end +