Mercurial > hg > camir-aes2014
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function p = myismember(a,A) | |
2 % MYISMEMBER Is 'a' an element of a set of positive integers? (much faster than built-in ismember) | |
3 % p = myismember(a,A) | |
4 | |
5 %if isempty(A) | a < min(A) | a > max(A) % slow | |
6 | |
7 if length(A)==0 | |
8 p = 0; | |
9 elseif a < min(A) | |
10 p = 0; | |
11 elseif a > max(A) | |
12 p = 0; | |
13 else | |
14 bits = zeros(1, max(A)); | |
15 bits(A) = 1; | |
16 p = bits(a); | |
17 end | |
18 p = logical(p); |