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