Home > vbmeg > functions > common > utility > vb_setdiff2.m

vb_setdiff2

PURPOSE ^

Fast calculation of set difference 'setdiff' for interger index

SYNOPSIS ^

function idiff = vb_setdiff2(inew,iold)

DESCRIPTION ^

 Fast calculation of set difference 'setdiff' for interger index
 idiff = vb_setdiff2(inew,iold)
 --- Input
 inew , iold : Integer index array
 --- Output
 idiff : index in 'inew' which is not included in 'iold'

 inew の要素で iold の要素でない値を idiff に出力
 inew , iold , idiff は整数

 Ver 1.0 written by M. Sato  2003-3-15

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    idiff = vb_setdiff2(inew,iold)
0002 % Fast calculation of set difference 'setdiff' for interger index
0003 % idiff = vb_setdiff2(inew,iold)
0004 % --- Input
0005 % inew , iold : Integer index array
0006 % --- Output
0007 % idiff : index in 'inew' which is not included in 'iold'
0008 %
0009 % inew の要素で iold の要素でない値を idiff に出力
0010 % inew , iold , idiff は整数
0011 %
0012 % Ver 1.0 written by M. Sato  2003-3-15
0013 %
0014 % Copyright (C) 2011, ATR All Rights Reserved.
0015 % License : New BSD License(see VBMEG_LICENSE.txt)
0016 
0017 inew  = inew(:);
0018 iold  = iold(:);
0019 
0020 N      = max([inew ; iold]);
0021 
0022 jflag = zeros(N,1);
0023 imask = ones(N,1);
0024 
0025 jflag(inew) = 1;     % inew のインデックスに 1 のフラグを立てる
0026 imask(iold) = 0;    % iold のインデックスに 0 のマスク
0027 
0028 jflag = jflag.*imask; 
0029 
0030 idiff = find(jflag==1);

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005