matthiasm@8: function C = myintersect(A,B) matthiasm@8: % MYINTERSECT Intersection of two sets of positive integers (much faster than built-in intersect) matthiasm@8: % C = myintersect(A,B) matthiasm@8: matthiasm@8: A = A(:)'; B = B(:)'; matthiasm@8: matthiasm@8: if isempty(A) matthiasm@8: ma = 0; matthiasm@8: else matthiasm@8: ma = max(A); matthiasm@8: end matthiasm@8: matthiasm@8: if isempty(B) matthiasm@8: mb = 0; matthiasm@8: else matthiasm@8: mb = max(B); matthiasm@8: end matthiasm@8: matthiasm@8: if ma==0 | mb==0 matthiasm@8: C = []; matthiasm@8: else matthiasm@8: %bits = sparse(1, max(ma,mb)); matthiasm@8: bits = zeros(1, max(ma,mb)); matthiasm@8: bits(A) = 1; matthiasm@8: C = B(logical(bits(B))); matthiasm@8: end matthiasm@8: matthiasm@8: %sum( bitget( bitand( cliquesb(i), cliquesb(j) ), 1:52 ) );