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