about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/KPMtools/myismember.m~
blob: 6c93c11a0fd044e7fb4863efdb0d9ffc904901d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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