comparison toolboxes/FullBNT-1.0.7/KPMtools/myintersect.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
1 function C = myintersect(A,B)
2 % MYINTERSECT Intersection of two sets of positive integers (much faster than built-in intersect)
3 % C = myintersect(A,B)
4
5 A = A(:)'; B = B(:)';
6
7 if isempty(A)
8 ma = 0;
9 else
10 ma = max(A);
11 end
12
13 if isempty(B)
14 mb = 0;
15 else
16 mb = max(B);
17 end
18
19 if ma==0 | mb==0
20 C = [];
21 else
22 %bits = sparse(1, max(ma,mb));
23 bits = zeros(1, max(ma,mb));
24 bits(A) = 1;
25 C = B(logical(bits(B)));
26 end
27
28 %sum( bitget( bitand( cliquesb(i), cliquesb(j) ), 1:52 ) );