Added source Matlab code for reference
This commit is contained in:
parent
b8af977117
commit
b5d99903d2
186 changed files with 61405 additions and 1 deletions
17
matlab/parallel/sort_partition.m
Normal file
17
matlab/parallel/sort_partition.m
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
function srt_partition = sort_partition(partition)
|
||||
% SORT_PARTITION sorts a given partition (row vector) into the canonical order, where every
|
||||
% new class has the smallest possible index.
|
||||
|
||||
% input:
|
||||
% partition is a column vector.
|
||||
% output:
|
||||
% srt_partition is a row vector.
|
||||
|
||||
n_classes=max(partition);
|
||||
srt_partition=zeros(1,n_classes);
|
||||
for i=1:n_classes
|
||||
nonz=find(partition);
|
||||
here=find(partition==partition(nonz(1)));
|
||||
srt_partition(here)=i;
|
||||
partition(here)=0;
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue