MatrixBerryCore
unionjoint.m
Go to the documentation of this file.
1 function [unionCell,indLeft,indRight,indLocLeftVec,indLocRightVec]=unionjoint(leftCell,rightCell)
2 import mxberry.core.ismemberjoint;
3 import mxberry.core.uniquejoint;
4 catCell=cellfun(@smartcat,leftCell,rightCell,'UniformOutput',false);
5 %
6 unionCell=uniquejoint(catCell);
7 [~,indLeft]=ismemberjoint(leftCell,unionCell);
8 [~,indRight]=ismemberjoint(rightCell,unionCell);
9 nUnionElems=max(max(indLeft),max(indRight));
10 indLocLeftVec=zeros(1,nUnionElems);
11 indLocRightVec=indLocLeftVec;
12 %
13 indLocLeftVec(indLeft)=1:numel(indLeft);
14 indLocRightVec(indRight)=1:numel(indRight);
15 %
16 
17 function catArray=smartcat(xArray,yArray)
18 import mxberry.core.throwerror;
19 %
20 isXOk=numel(xArray)==length(xArray);
21 isYOk=numel(yArray)==length(yArray);
22 %
23 if ~(isXOk||isYOk)
24  throwerror('incorrectInput',...
25  ['corresponding cell items in input cell arrays should ',...
26  'be both either rows or colums']);
27 end
28 isXRow=size(xArray,1)==1;
29 isYRow=size(xArray,1)==1;
30 catDim=max(isXRow,isYRow)+1;
31 catArray=cat(catDim,xArray,yArray);
function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...
function smartcat(in xArray, in yArray)
function ismemberjoint(in leftCArr, in rightCArr, in varargin)
ISMEMBERJOINT perform joint ismember operation for two cell arrays.
function uniquejoint(in inpCArr, in varargin)
UNIQUEJOINT perform joint unique operation for cell arrays.
function unionjoint(in leftCell, in rightCell)
UNIONJOINT calculates union of corresponding elements of two cell arrays jointly accross all cell arr...
function cat(in dimNum, in varargin)