view 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
line wrap: on
line source
function p = myismember(a,A)
% MYISMEMBER Is 'a' an element of a set of positive integers? (much faster than built-in ismember)
% p = myismember(a,A)

%if isempty(A) | a < min(A) | a > max(A)  % slow

if length(A)==0
  p = 0;
elseif a < min(A)
  p = 0;
elseif a > max(A)
  p = 0;
else
  bits = zeros(1, max(A));
  bits(A) = 1;
  p = bits(a);
end
p = logical(p);