comparison toolboxes/FullBNT-1.0.7/KPMtools/mysetdiff.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 = mysetdiff(A,B)
2 % MYSETDIFF Set difference of two sets of positive integers (much faster than built-in setdiff)
3 % C = mysetdiff(A,B)
4 % C = A \ B = { things in A that are not in B }
5 %
6 % Original by Kevin Murphy, modified by Leon Peshkin
7
8 if isempty(A)
9 C = [];
10 return;
11 elseif isempty(B)
12 C = A;
13 return;
14 else % both non-empty
15 bits = zeros(1, max(max(A), max(B)));
16 bits(A) = 1;
17 bits(B) = 0;
18 C = A(logical(bits(A)));
19 end