annotate _FullBNT/KPMtools/sort_evec.m @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
rev   line source
matthiasm@8 1 function [evec, evals] = sort_evec(temp_evec, temp_evals, N)
matthiasm@8 2
matthiasm@8 3 if ~isvector(temp_evals)
matthiasm@8 4 temp_evals = diag(temp_evals);
matthiasm@8 5 end
matthiasm@8 6
matthiasm@8 7 % Eigenvalues nearly always returned in descending order, but just
matthiasm@8 8 % to make sure.....
matthiasm@8 9 [evals perm] = sort(-temp_evals);
matthiasm@8 10 evals = -evals(1:N);
matthiasm@8 11 if evals == temp_evals(1:N)
matthiasm@8 12 % Originals were in order
matthiasm@8 13 evec = temp_evec(:, 1:N);
matthiasm@8 14 return
matthiasm@8 15 else
matthiasm@8 16 fprintf('sorting evec\n');
matthiasm@8 17 % Need to reorder the eigenvectors
matthiasm@8 18 for i=1:N
matthiasm@8 19 evec(:,i) = temp_evec(:,perm(i));
matthiasm@8 20 end
matthiasm@8 21 end
matthiasm@8 22