annotate 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
rev   line source
wolffd@0 1 function C = myintersect(A,B)
wolffd@0 2 % MYINTERSECT Intersection of two sets of positive integers (much faster than built-in intersect)
wolffd@0 3 % C = myintersect(A,B)
wolffd@0 4
wolffd@0 5 A = A(:)'; B = B(:)';
wolffd@0 6
wolffd@0 7 if isempty(A)
wolffd@0 8 ma = 0;
wolffd@0 9 else
wolffd@0 10 ma = max(A);
wolffd@0 11 end
wolffd@0 12
wolffd@0 13 if isempty(B)
wolffd@0 14 mb = 0;
wolffd@0 15 else
wolffd@0 16 mb = max(B);
wolffd@0 17 end
wolffd@0 18
wolffd@0 19 if ma==0 | mb==0
wolffd@0 20 C = [];
wolffd@0 21 else
wolffd@0 22 %bits = sparse(1, max(ma,mb));
wolffd@0 23 bits = zeros(1, max(ma,mb));
wolffd@0 24 bits(A) = 1;
wolffd@0 25 C = B(logical(bits(B)));
wolffd@0 26 end
wolffd@0 27
wolffd@0 28 %sum( bitget( bitand( cliquesb(i), cliquesb(j) ), 1:52 ) );