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