MatrixBerryCore
updatetypeinfostruct.m
Go to the documentation of this file.
1 function STypeInfo = updatetypeinfostruct(SOldTypeInfo)
2 if ~isfield(SOldTypeInfo,'itemTypeInfo')
3  %nothing to update
4  STypeInfo=SOldTypeInfo;
5 else
6 
7  maxDepth=nan;
8  bottomType='';
9  %
10  if isfield(SOldTypeInfo,'isNested')
11  getbottomtype_v1(SOldTypeInfo,0);
12  elseif isfield(SOldTypeInfo,'isCell')
13  getbottomtype_v2(SOldTypeInfo,0);
14  else
15  mxberry.core.throwerror('wrongInput',...
16  'unknown format of STypeInfo');
17  end
18  %
19  STypeInfo=struct('type',bottomType,'depth',maxDepth);
20 end
21 %
22  function getbottomtype_v1(STypeInfo,level)
23  if STypeInfo.isNested
24  getbottomtype_v1(STypeInfo.itemTypeInfo,level+1)
25  else
26  maxDepth=level;
27  bottomType=STypeInfo.type;
28  end
29  end
30  function getbottomtype_v2(STypeInfo,level)
31  if STypeInfo.isCell
32  getbottomtype_v2(STypeInfo.itemTypeInfo,level+1)
33  else
34  maxDepth=level;
35  bottomType=STypeInfo.type;
36  end
37  end
38 end
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 updatetypeinfostruct(in SOldTypeInfo)
function getbottomtype_v1(in STypeInfo, in level)
function getbottomtype_v2(in STypeInfo, in level)