diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toolboxes/FullBNT-1.0.7/KPMtools/myismember.m	Tue Feb 10 15:05:51 2015 +0000
@@ -0,0 +1,18 @@
+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);