-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_unique.m
38 lines (34 loc) · 1.1 KB
/
find_unique.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function [X,Y] = find_unique(solution,index)
K = numel(solution);
d = size(cell2mat(solution(1)),1);
smarker = [];
s = 1;
% Check which entry j of solution is equal to entry k of solution
% after an appropriate shuffle.
for k = 1:K
for j = k+1:K
CS1 = cell2mat(solution(k)); % CS1 and CS2 are the complex matrices after all possible merging
CS2 = cell2mat(solution(j));
if numel(CS1(1,:)) == numel(CS2(1,:))
M = numel(CS1(1,:))/2;
Shuffle3 = perms(1:M);
for i = 1:numel(Shuffle3(:,1))
CS22 = zeros(d, 2*M);
for r = 1:M
CS22(:,2*r-1) = CS2(:,2*Shuffle3(i,r)-1); % clon of CS2 after shuffling
CS22(:,2*r) = CS2(:,2*Shuffle3(i,r));
end
if isequal(CS22,CS1)
smarker(s) = j;
s = s + 1;
end
end
end
end
end
smarker = unique(smarker);
solution(smarker) = [];
index(smarker,:) = [];
X = solution;
Y = index;
end