Mercurial > hg > camir-ismir2012
comparison toolboxes/FullBNT-1.0.7/KPMtools/myismember.m @ 0:cc4b1211e677 tip
initial commit to HG from
Changeset:
646 (e263d8a21543) added further path and more save "camirversion.m"
author | Daniel Wolff |
---|---|
date | Fri, 19 Aug 2016 13:07:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cc4b1211e677 |
---|---|
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); |