annotate toolboxes/FullBNT-1.0.7/KPMtools/myismember.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function p = myismember(a,A)
wolffd@0 2 % MYISMEMBER Is 'a' an element of a set of positive integers? (much faster than built-in ismember)
wolffd@0 3 % p = myismember(a,A)
wolffd@0 4
wolffd@0 5 %if isempty(A) | a < min(A) | a > max(A) % slow
wolffd@0 6
wolffd@0 7 if length(A)==0
wolffd@0 8 p = 0;
wolffd@0 9 elseif a < min(A)
wolffd@0 10 p = 0;
wolffd@0 11 elseif a > max(A)
wolffd@0 12 p = 0;
wolffd@0 13 else
wolffd@0 14 bits = zeros(1, max(A));
wolffd@0 15 bits(A) = 1;
wolffd@0 16 p = bits(a);
wolffd@0 17 end
wolffd@0 18 p = logical(p);