Mercurial > hg > mauch-mirex-2010
annotate _FullBNT/KPMtools/myintersect.m @ 9:4ea6619cb3f5 tip
removed log files
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:55:11 +0100 |
parents | b5b38998ef3b |
children |
rev | line source |
---|---|
matthiasm@8 | 1 function C = myintersect(A,B) |
matthiasm@8 | 2 % MYINTERSECT Intersection of two sets of positive integers (much faster than built-in intersect) |
matthiasm@8 | 3 % C = myintersect(A,B) |
matthiasm@8 | 4 |
matthiasm@8 | 5 A = A(:)'; B = B(:)'; |
matthiasm@8 | 6 |
matthiasm@8 | 7 if isempty(A) |
matthiasm@8 | 8 ma = 0; |
matthiasm@8 | 9 else |
matthiasm@8 | 10 ma = max(A); |
matthiasm@8 | 11 end |
matthiasm@8 | 12 |
matthiasm@8 | 13 if isempty(B) |
matthiasm@8 | 14 mb = 0; |
matthiasm@8 | 15 else |
matthiasm@8 | 16 mb = max(B); |
matthiasm@8 | 17 end |
matthiasm@8 | 18 |
matthiasm@8 | 19 if ma==0 | mb==0 |
matthiasm@8 | 20 C = []; |
matthiasm@8 | 21 else |
matthiasm@8 | 22 %bits = sparse(1, max(ma,mb)); |
matthiasm@8 | 23 bits = zeros(1, max(ma,mb)); |
matthiasm@8 | 24 bits(A) = 1; |
matthiasm@8 | 25 C = B(logical(bits(B))); |
matthiasm@8 | 26 end |
matthiasm@8 | 27 |
matthiasm@8 | 28 %sum( bitget( bitand( cliquesb(i), cliquesb(j) ), 1:52 ) ); |