Mercurial > hg > camir-aes2014
annotate 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 |
rev | line source |
---|---|
wolffd@0 | 1 function [evec, evals] = sort_evec(temp_evec, temp_evals, N) |
wolffd@0 | 2 |
wolffd@0 | 3 if ~isvectorBNT(temp_evals) |
wolffd@0 | 4 temp_evals = diag(temp_evals); |
wolffd@0 | 5 end |
wolffd@0 | 6 |
wolffd@0 | 7 % Eigenvalues nearly always returned in descending order, but just |
wolffd@0 | 8 % to make sure..... |
wolffd@0 | 9 [evals perm] = sort(-temp_evals); |
wolffd@0 | 10 evals = -evals(1:N); |
wolffd@0 | 11 if evals == temp_evals(1:N) |
wolffd@0 | 12 % Originals were in order |
wolffd@0 | 13 evec = temp_evec(:, 1:N); |
wolffd@0 | 14 return |
wolffd@0 | 15 else |
wolffd@0 | 16 fprintf('sorting evec\n'); |
wolffd@0 | 17 % Need to reorder the eigenvectors |
wolffd@0 | 18 for i=1:N |
wolffd@0 | 19 evec(:,i) = temp_evec(:,perm(i)); |
wolffd@0 | 20 end |
wolffd@0 | 21 end |
wolffd@0 | 22 |