comparison toolboxes/FullBNT-1.0.7/KPMtools/myintersect.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 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 ) );