Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/KPMtools/find_equiv_posns.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 = find_equiv_posns(vsmall, vlarge) | |
2 % FIND_EQUIV_POSNS p[i] = the place where vsmall[i] occurs in vlarge. | |
3 % p = find_equiv_posns(vsmall, vlarge) | |
4 % THE VECTORS ARE ASSUMED TO BE SORTED. | |
5 % | |
6 % e.g., vsmall=[2,8], vlarge=[2,7,8,4], p=[1,3] | |
7 % | |
8 % In R/S, this function is called 'match' | |
9 | |
10 %if ~mysubset(vsmall, vlarge) | |
11 % error('small domain must occur in large domain'); | |
12 %end | |
13 | |
14 if isempty(vsmall) | isempty(vlarge) | |
15 p = []; | |
16 return; | |
17 end | |
18 | |
19 bitvec = sparse(1, max(vlarge)); | |
20 %bitvec = zeros(1, max(vlarge)); | |
21 bitvec(vsmall) = 1; | |
22 p = find(bitvec(vlarge)); | |
23 | |
24 %p = find(ismember(vlarge, vsmall)); % slower |