Revision: 2057
Author:
Alexander...@gmail.com
Date: Tue Jun 18 13:33:55 2013
Log: Issue 66.
Another pack of fixes added.
http://code.google.com/p/ellipsoids/source/detail?r=2057
Added:
/branches/issue_66_akarev/lib/+modgen/+struct/+test/StructDispTC.m
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/fromRepMat.m
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/getCopy.m
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/isEmpty.m
Deleted:
/branches/issue_66_akarev/lib/+modgen/+struct/+test/mlunit_test_mixed.m
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/StrucdispTC.m
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/isempty.m
Modified:
/branches/issue_66_akarev/lib/+modgen/+struct/+test/run_tests.m
/branches/issue_66_akarev/lib/NoPkg/StructCell/strucdisp.m
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/ADispStructTC.m
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/EllipsoidDispStructTC.m
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/EllipsoidTestCase.m
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/HyperplaneDispStructTC.m
/branches/issue_66_akarev/products/+elltool/+core/+test/run_tests.m
/branches/issue_66_akarev/products/elltoolboxcore/@ellipsoid/eq.m
/branches/issue_66_akarev/products/elltoolboxcore/@ellipsoid/toStruct.m
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/hyperplane.m
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/toStruct.m
=======================================
--- /dev/null
+++ /branches/issue_66_akarev/lib/+modgen/+struct/+test/StructDispTC.m Tue
Jun 18 13:33:55 2013
@@ -0,0 +1,271 @@
+classdef StructDispTC < mlunitext.test_case
+ %
+ %$Author: Alexander Karev <
Alexander...@gmail.com> $
+ %$Date: 2013-06$
+ %$Copyright: Moscow State University,
+ % Faculty of Computational Mathematics
+ % and Computer Science,
+ % System Analysis Department 2013 $
+ properties (Access=private)
+ testDataRootDir
+ resTmpDir
+ end
+ methods
+ function self = StructDispTC(varargin)
+ self = se...@mlunitext.test_case(varargin{:});
+ end
+ function self = set_up_param(self,varargin)
+ end
+ %
+ function self = set_up(self)
+ self.resTmpDir=modgen.test.TmpDataManager.getDirByCallerKey();
+ end
+ function self = tear_down(self)
+ rmdir(self.resTmpDir,'s');
+ end
+ %
+ function self = test_strucdisp(self)
+ S.name='';
+ S.description=[];
+ %
+ res=evalc('strucdisp(S)');
+ ind=strfind(res,'name');
+ mlunitext.assert_equals(1,numel(ind));
+ ind=strfind(res,'description');
+ mlunitext.assert_equals(1,numel(ind));
+ end
+ function testStruct2Str(self)
+ S.alpha=1;
+ S.beta=2;
+ S.gamma.alpha=1;
+ S.gamma.beta=2;
+ resStr=strucdisp(S);
+ resStr2=modgen.struct.struct2str(S);
+ mlunitext.assert_equals(true,isequal(resStr,resStr2));
+ end
+ function testStrucDispSimpleRegress(self)
+ S.alpha=1;
+ S.beta=2;
+ S.gamma.alpha=1;
+ S.gamma.beta=2;
+ expList={'| ';...
+ '|--- gamma';...
+ '| | ';...
+ '| |-- alpha : 1';...
+ '| |--- beta : 2';...
+ '| O';...
+ '| ';...
+ '|-- alpha : 1';...
+ '|--- beta : 2'};
+ check(S,expList);
+ function check(S,expList)
+ inpArgList={S,'depth',2,'printValues',true};
+ resStr=evalc('strucdisp(inpArgList{:})');
+ resStr2=strucdisp(inpArgList{:});
+ mlunitext.assert_equals(true,isequal(resStr,resStr2));
+ resList=textscan(resStr,'%s','delimiter','\n');
+ resList=resList{1};
+ mlunitext.assert_equals(true,isequal(resList,expList));
+ end
+ end
+ function testStrucDispRegress(self)
+ %
+ ARG_COMB_LIST={...
+ {'depth',100,'printValues',false,'maxArrayLength',100},...
+ {'depth',100,'printValues',true,'maxArrayLength',100},...
+ {'depth',2,'printValues',true},...
+ {'depth',100,'printValues',true},...
+ {'depth',100,'printValues',false}};
+ %
+ methodName=modgen.common.getcallernameext(1);
+
inpFileName=[self.testDataRootDir,filesep,[methodName,'_inp.mat']];
+
+ resMap=modgen.containers.ondisk.HashMapMatXML(...
+ 'storageLocationRoot',self.testDataRootDir,...
+ 'storageBranchKey',[methodName,'_out'],'storageFormat','mat',...
+ 'useHashedPath',false,'useHashedKeys',true);
+ SData=load(inpFileName);
+ structNameList=fieldnames(SData);
+ nFields=length(structNameList);
+ nArgCombs=length(ARG_COMB_LIST);
+ %
+ resTmpDir=self.resTmpDir;
+ resFileName=[resTmpDir,filesep,'out.txt'];
+ for iField=1:nFields
+ structName=structNameList{iField};
+ S=SData.(structName);
+ for iArgComb=1:nArgCombs
+ inpArgList=ARG_COMB_LIST{iArgComb};
+ resStr=evalc('strucdisp(S,inpArgList{:})');
+ inpKey=hash({S,inpArgList});
+ SRes.S=S;
+ SRes.inpArgList=inpArgList;
+ SRes.resStr=resStr;
+ %
+ %resMap.put(inpKey,SRes);
+ SExpRes=resMap.get(inpKey);
+ [isPos,reportStr]=...
+ modgen.struct.structcompare(SRes,SExpRes);
+ mlunitext.assert_equals(true,isPos,reportStr);
+ %
+ evalc('strucdisp(S,resFileName,inpArgList{:});');
+ fid=fopen(resFileName,'r');
+ try
+
resCell=textscan(fid,'%[^\n]','delimiter','','whitespace','');
+ resFileStr=sprintf('%s\n',resCell{1}{:});
+ catch meObj
+ fclose(fid);
+ rethrow(fid);
+ end
+ fclose(fid);
+ delete(resFileName);
+
mlunitext.assert_equals(true,isequal(resFileStr,resStr));
+ end
+ end
+ %
+ end
+ function testGetLeaveList(~)
+ Data=modgen.common.genteststruct(0);
+ check();
+ Data=struct();
+ Data.alpha(2,1).a=2;
+ Data.alpha(2,4).a=6;
+ check();
+ Data=struct();
+ Data.alpha(1).a=2;
+ Data.alpha(4).a=6;
+ check();
+ Data=struct();
+ Data.alpha(2,1,5).a=2;
+ Data.alpha(2,4,4).a=6;
+ %
+ check();
+ function SRes=check()
+ SRes=checkGetField();
+ compare();
+ SRes=checkValue();
+ compare();
+ %
+ function compare()
+
[isEqual,reportStr]=modgen.struct.structcompare(SRes,Data);
+ mlunitext.assert_equals(true,isEqual,reportStr);
+
mlunitext.assert_equals(true,isequalwithequalnans(SRes,Data));
+ end
+ function SRes=checkValue()
+
[pathSpecList,valList]=modgen.struct.getleavelist(Data);
+ nPaths=numel(pathSpecList);
+ SRes=struct();
+ for iPath=1:nPaths
+ SRes=setfield(SRes,pathSpecList{iPath}{:},...
+ valList{iPath});
+ end
+ end
+ function SRes=checkGetField()
+ pathSpecList=modgen.struct.getleavelist(Data);
+ nPaths=numel(pathSpecList);
+ SRes=struct();
+ for iPath=1:nPaths
+ SRes=setfield(SRes,pathSpecList{iPath}{:},...
+ getfield(Data,pathSpecList{iPath}{:}));
+ end
+ end
+ end
+ end
+ function test_updateLeaves(~)
+ import modgen.struct.updateleavesext;
+ SData.a.b=1;
+ SRes=updateleavesext(SData,@fTransform);
+ %
+
SExp.a.bb=1;
+ mlunitext.assert_equals(true,isequal(SRes,SExp));
+ %
+ function [val,path]=fTransform(val,path)
+ path{4}=repmat(path{4},1,2);
+ end
+ end
+ function testGetUpdateLeaves(~)
+ checkPathList(modgen.struct.getleavelist(struct()));
+ %
+ SData.a.b=1;
+ SData.a.c=20;
+ SData.b.a.d=1;
+ SData.c=10;
+ SData.d='c';
+ SData.alpha.beta.gamma.theta=2;
+ SData.alpha.beta.gamma.delta='vega';
+ SData.alpha.beta.gamma.delta2=1;
+ %
+ check();
+ SData=struct();
+ check();
+ SData=modgen.common.genteststruct(0);
+ check();
+ function check()
+ SRes=modgen.struct.updateleaves(SData,@(x,y)x);
+ mlunitext.assert_equals(true,...
+ isequalwithequalnans(SData,SRes));
+ SRes=modgen.struct.updateleaves(SData,@fMinus);
+ SRes=modgen.struct.updateleaves(SRes,@fMinus);
+ mlunitext.assert_equals(true,...
+ isequalwithequalnans(SData,SRes));
+ %
+ pathExpList=modgen.struct.getleavelist(SData);
+ pathList={};
+ %
+ modgen.struct.updateleaves(SRes,@storePath);
+
mlunitext.assert_equals(true,isequal(pathList,pathExpList));
+ %
+ function value=storePath(value,subFieldNameList)
+ pathList=[pathList;{subFieldNameList}];
+ end
+ function x=fMinus(x,~)
+ if isnumeric(x)
+ x=-x;
+ end
+ end
+ end
+ function checkPathList(pathList)
+ import modgen.common.type.simple.lib.iscellofstring;
+ mlunitext.assert_equals(true,iscell(pathList));
+ if ~isempty(pathList)
+ mlunitext.assert_equals(true,...
+ all(cellfun('isclass',pathList,'cell')));
+ mlunitext.assert_equals(true,...
+ iscellofstring([pathList{:}]));
+ end
+ end
+ end
+
+ function self = testArrays(self)
+ S = struct('a', 1);
+ str = evalc('strucdisp(S)');
+ isOk = ~isempty(strfind(str, '1'));
+
+ S = struct('a', [1 2 3]);
+ str = evalc('strucdisp(S)');
+ isOk = isOk & ~isempty(strfind(str, '[1 2 3]'));
+
+ S = struct('a', ones(5, 3, 2));
+ str = evalc('strucdisp(S)');
+ isOk = isOk & ~isempty(strfind(str, '[5x3x2 Array]'));
+
+ mlunitext.assert_equals(isOk, true);
+ end
+
+ function self = testLogicalFields(self)
+ S = struct('a', false(1, 2));
+ str = evalc('strucdisp(S)');
+ isOk = ~isempty(strfind(str, '[false false]'));
+
+ S = struct('a', false);
+ str = evalc('strucdisp(S)');
+ isOk = isOk & ~isempty(strfind(str, 'false'));
+
+ S = struct('a', false(5));
+ str = evalc('strucdisp(S)');
+ isOk = isOk & ~isempty(strfind(str, '[5x5 Logic array]'));
+
+ mlunitext.assert_equals(isOk, true);
+ end
+ end
+end
=======================================
--- /dev/null
+++
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/fromRepMat.m
Tue Jun 18 13:33:55 2013
@@ -0,0 +1,73 @@
+function hpArr = fromRepMat(varargin)
+% FROMREPMAT - returns array of equal hyperplanes the same
+% size as stated in sizeVec argument
+%
+% hpArr = fromRepMat(sizeVec) - creates an array size
+% sizeVec of empty hyperplanes.
+%
+% hpArr = fromRepMat(normalVec,sizeVec) - creates an array
+% size sizeVec of hyperplanes with normal
+% normalVec.
+%
+% hpArr = fromRepMat(normalVec,shift,sizeVec) - creates an
+% array size sizeVec of hyperplanes with normal normalVec
+% and hyperplane shift shift.
+%
+% Input:
+% Case1:
+% regular:
+% sizeVec: double[1,n] - vector of size, have
+% integer values.
+%
+% Case2:
+% regular:
+% normalVec: double[nDim, 1] - normal of
+% hyperplanes.
+% sizeVec: double[1, n] - vector of size, have
+% integer values.
+%
+% Case3:
+% regular:
+% normalVec: double[nDim, 1] - normal of
+% hyperplanes.
+% shift: double[1, 1] - shift of hyperplane.
+% sizeVec: double[1,n] - vector of size, have
+% integer values.
+%
+% properties:
+% absTol: double [1,1] - absolute tolerance with default
+% value 10^(-7)
+%
+% $Author: Alexander Karev <
Alexander...@gmail.com>
+% $Copyright: Moscow State University,
+% Faculty of Computational Mathematics
+% and Computer Science,
+% System Analysis Department 2013 $
+%
+
+import modgen.common.checkvar;
+%
+if nargin > 3
+ indVec = [1:2,4:nargin];
+ sizeVec = varargin{3};
+else
+ sizeVec = varargin{nargin};
+ indVec = [1:nargin-1];
+end
+%
+checkvar(sizeVec,@(x) isa(x,'double')&&all(isreal(x(:)))&&...
+ all(mod(x(:),1) == 0) && all(x(:) > 0) && (size(x,1) == 1),...
+ 'errorTag','wrongInput','errorMessage',...
+ 'size array must contain positive integer values.');
+%
+nHyperplanes = prod(sizeVec);
+hpArr(nHyperplanes) = hyperplane();
+%
+hp = hyperplane(varargin{indVec});
+arrayfun(@(x)makeHyperplane(x),1:nHyperplanes);
+hpArr = reshape(hpArr,sizeVec);
+%
+ function makeHyperplane(index)
+ hpArr(index) = getCopy(hp);
+ end
+end
=======================================
--- /dev/null
+++ /branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/getCopy.m
Tue Jun 18 13:33:55 2013
@@ -0,0 +1,44 @@
+function copyHpArr = getCopy(hpArr)
+% GETCOPY - gives array the same size as hpArr with copies of elements of
+% hpArr.
+%
+% Input:
+% regular:
+% hpArr: hyperplane[nDim1, nDim2,...] - multidimensional array of
+% hyperplanes.
+%
+% Output:
+% copyHpArr: hyperplane[nDim1, nDim2,...] - multidimension array of
+% copies of elements of hpArr.
+%
+% Example:
+% firstHpObj = hyperplane([-1; 1], [2 0; 0 3]);
+% secHpObj = hyperplane([1; 2], eye(2));
+% hpVec = [firstHpObj secHpObj];
+% copyHpVec = getCopy(hpVec)
+%
+% copyHpVec =
+% 1x2 array of hyperplanes.
+%
+%
+% $Author: Alexander Karev <
Alexander...@gmail.com>
+% $Copyright: Moscow State University,
+% Faculty of Computational Mathematics
+% and Computer Science,
+% System Analysis Department 2013 $
+if isempty(hpArr)
+ copyHpArr = hyperplane.empty(size(hpArr));
+elseif isscalar(hpArr)
+ copyHpArr=hyperplane();
+ fSingleCopy(copyHpArr,hpArr);
+else
+ sizeCVec = num2cell(size(hpArr));
+ copyHpArr(sizeCVec{:}) = hyperplane();
+ arrayfun(@fSingleCopy,copyHpArr,hpArr);
+end
+ function fSingleCopy(copyHp,hp)
+ copyHp.normal = hp.normal;
+ copyHp.shift = hp.shift;
+ copyHp.absTol = hp.absTol;
+ end
+end
=======================================
--- /dev/null
+++ /branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/isEmpty.m
Tue Jun 18 13:33:55 2013
@@ -0,0 +1,35 @@
+function isPositiveArr = isEmpty(myHypArr)
+%
+% ISEMPTY - checks if hyperplanes in H are empty.
+%
+% Input:
+% regular:
+% myHypArr: hyperplane [nDims1, nDims2, ...] - array
+% of hyperplanes.
+%
+% Output:
+% isPositiveArr: logical[nDims1, nDims2, ...],
+% isPositiveArr(iDim1, iDim2, ...) = true - if ellipsoid
+% myHypArr(iDim1, iDim2, ...) is empty, false - otherwise.
+%
+% Example:
+% hypObj = hyperplane();
+% isempty(hypObj)
+%
+% ans =
+%
+% 1
+%
+% $Author: Alex Kurzhanskiy <
akur...@eecs.berkeley.edu>
+% $Copyright: The Regents of the University of California
+% 2004-2008 $
+%
+% $Author: Aushkap Nikolay <
n.au...@gmail.com> $
+% $Date: 30-11-2012$
+% $Copyright: Moscow State University,
+% Faculty of Computational Mathematics
+% and Computer Science,
+% System Analysis Department 2012 $
+
+hyperplane.checkIsMe(myHypArr);
+isPositiveArr = (dimension(myHypArr) == 0);
=======================================
--- /branches/issue_66_akarev/lib/+modgen/+struct/+test/mlunit_test_mixed.m
Mon Jun 17 15:11:19 2013
+++ /dev/null
@@ -1,236 +0,0 @@
-classdef mlunit_test_mixed < mlunitext.test_case
- properties (Access=private)
- testDataRootDir
- resTmpDir
- end
- methods
- function self = set_up_param(self,varargin)
- end
- %
- function self = set_up(self)
- self.resTmpDir=modgen.test.TmpDataManager.getDirByCallerKey();
- end
- function self = tear_down(self)
- rmdir(self.resTmpDir,'s');
- end
- %
- function self = mlunit_test_mixed(varargin)
- self = se...@mlunitext.test_case(varargin{:});
- [~,className]=modgen.common.getcallernameext(1);
- shortClassName=mfilename('classname');
-
self.testDataRootDir=[fileparts(which(className)),filesep,'TestData',...
- filesep,shortClassName];
- end
- function self = test_strucdisp(self)
- S.name='';
- S.description=[];
- %
- res=evalc('strucdisp(S)');
- ind=strfind(res,'name');
- mlunitext.assert_equals(1,numel(ind));
- ind=strfind(res,'description');
- mlunitext.assert_equals(1,numel(ind));
- end
- function testStruct2Str(self)
- S.alpha=1;
- S.beta=2;
- S.gamma.alpha=1;
- S.gamma.beta=2;
- resStr=strucdisp(S);
- resStr2=modgen.struct.struct2str(S);
- mlunitext.assert_equals(true,isequal(resStr,resStr2));
- end
- function testStrucDispSimpleRegress(self)
- S.alpha=1;
- S.beta=2;
- S.gamma.alpha=1;
- S.gamma.beta=2;
- expList={'| ';...
- '|--- gamma';...
- '| | ';...
- '| |-- alpha : 1';...
- '| |--- beta : 2';...
- '| O';...
- '| ';...
- '|-- alpha : 1';...
- '|--- beta : 2'};
- check(S,expList);
- function check(S,expList)
- inpArgList={S,'depth',2,'printValues',true};
- resStr=evalc('strucdisp(inpArgList{:})');
- resStr2=strucdisp(inpArgList{:});
- mlunitext.assert_equals(true,isequal(resStr,resStr2));
- resList=textscan(resStr,'%s','delimiter','\n');
- resList=resList{1};
- mlunitext.assert_equals(true,isequal(resList,expList));
- end
- end
- function testStrucDispRegress(self)
- %
- ARG_COMB_LIST={...
- {'depth',100,'printValues',false,'maxArrayLength',100},...
- {'depth',100,'printValues',true,'maxArrayLength',100},...
- {'depth',2,'printValues',true},...
- {'depth',100,'printValues',true},...
- {'depth',100,'printValues',false}};
- %
- methodName=modgen.common.getcallernameext(1);
-
inpFileName=[self.testDataRootDir,filesep,[methodName,'_inp.mat']];
-
- resMap=modgen.containers.ondisk.HashMapMatXML(...
- 'storageLocationRoot',self.testDataRootDir,...
- 'storageBranchKey',[methodName,'_out'],'storageFormat','mat',...
- 'useHashedPath',false,'useHashedKeys',true);
- SData=load(inpFileName);
- structNameList=fieldnames(SData);
- nFields=length(structNameList);
- nArgCombs=length(ARG_COMB_LIST);
- %
- resTmpDir=self.resTmpDir;
- resFileName=[resTmpDir,filesep,'out.txt'];
- for iField=1:nFields
- structName=structNameList{iField};
- S=SData.(structName);
- for iArgComb=1:nArgCombs
- inpArgList=ARG_COMB_LIST{iArgComb};
- resStr=evalc('strucdisp(S,inpArgList{:})');
- inpKey=hash({S,inpArgList});
- SRes.S=S;
- SRes.inpArgList=inpArgList;
- SRes.resStr=resStr;
- %
- %resMap.put(inpKey,SRes);
- SExpRes=resMap.get(inpKey);
- [isPos,reportStr]=...
- modgen.struct.structcompare(SRes,SExpRes);
- mlunitext.assert_equals(true,isPos,reportStr);
- %
- evalc('strucdisp(S,resFileName,inpArgList{:});');
- fid=fopen(resFileName,'r');
- try
-
resCell=textscan(fid,'%[^\n]','delimiter','','whitespace','');
- resFileStr=sprintf('%s\n',resCell{1}{:});
- catch meObj
- fclose(fid);
- rethrow(fid);
- end
- fclose(fid);
- delete(resFileName);
-
mlunitext.assert_equals(true,isequal(resFileStr,resStr));
- end
- end
- %
- end
- function testGetLeaveList(~)
- Data=modgen.common.genteststruct(0);
- check();
- Data=struct();
- Data.alpha(2,1).a=2;
- Data.alpha(2,4).a=6;
- check();
- Data=struct();
- Data.alpha(1).a=2;
- Data.alpha(4).a=6;
- check();
- Data=struct();
- Data.alpha(2,1,5).a=2;
- Data.alpha(2,4,4).a=6;
- %
- check();
- function SRes=check()
- SRes=checkGetField();
- compare();
- SRes=checkValue();
- compare();
- %
- function compare()
-
[isEqual,reportStr]=modgen.struct.structcompare(SRes,Data);
- mlunitext.assert_equals(true,isEqual,reportStr);
-
mlunitext.assert_equals(true,isequalwithequalnans(SRes,Data));
- end
- function SRes=checkValue()
-
[pathSpecList,valList]=modgen.struct.getleavelist(Data);
- nPaths=numel(pathSpecList);
- SRes=struct();
- for iPath=1:nPaths
- SRes=setfield(SRes,pathSpecList{iPath}{:},...
- valList{iPath});
- end
- end
- function SRes=checkGetField()
- pathSpecList=modgen.struct.getleavelist(Data);
- nPaths=numel(pathSpecList);
- SRes=struct();
- for iPath=1:nPaths
- SRes=setfield(SRes,pathSpecList{iPath}{:},...
- getfield(Data,pathSpecList{iPath}{:}));
- end
- end
- end
- end
- function test_updateLeaves(~)
- import modgen.struct.updateleavesext;
- SData.a.b=1;
- SRes=updateleavesext(SData,@fTransform);
- %
-
SExp.a.bb=1;
- mlunitext.assert_equals(true,isequal(SRes,SExp));
- %
- function [val,path]=fTransform(val,path)
- path{4}=repmat(path{4},1,2);
- end
- end
- function testGetUpdateLeaves(~)
- checkPathList(modgen.struct.getleavelist(struct()));
- %
- SData.a.b=1;
- SData.a.c=20;
- SData.b.a.d=1;
- SData.c=10;
- SData.d='c';
- SData.alpha.beta.gamma.theta=2;
- SData.alpha.beta.gamma.delta='vega';
- SData.alpha.beta.gamma.delta2=1;
- %
- check();
- SData=struct();
- check();
- SData=modgen.common.genteststruct(0);
- check();
- function check()
- SRes=modgen.struct.updateleaves(SData,@(x,y)x);
- mlunitext.assert_equals(true,...
- isequalwithequalnans(SData,SRes));
- SRes=modgen.struct.updateleaves(SData,@fMinus);
- SRes=modgen.struct.updateleaves(SRes,@fMinus);
- mlunitext.assert_equals(true,...
- isequalwithequalnans(SData,SRes));
- %
- pathExpList=modgen.struct.getleavelist(SData);
- pathList={};
- %
- modgen.struct.updateleaves(SRes,@storePath);
-
mlunitext.assert_equals(true,isequal(pathList,pathExpList));
- %
- function value=storePath(value,subFieldNameList)
- pathList=[pathList;{subFieldNameList}];
- end
- function x=fMinus(x,~)
- if isnumeric(x)
- x=-x;
- end
- end
- end
- function checkPathList(pathList)
- import modgen.common.type.simple.lib.iscellofstring;
- mlunitext.assert_equals(true,iscell(pathList));
- if ~isempty(pathList)
- mlunitext.assert_equals(true,...
- all(cellfun('isclass',pathList,'cell')));
- mlunitext.assert_equals(true,...
- iscellofstring([pathList{:}]));
- end
- end
- end
- end
-end
=======================================
---
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/StrucdispTC.m
Thu Jun 13 13:56:53 2013
+++ /dev/null
@@ -1,46 +0,0 @@
-classdef StrucdispTC < mlunitext.test_case
- %
- %$Author: Alexander Karev <
Alexander...@gmail.com> $
- %$Date: 2013-06$
- %$Copyright: Moscow State University,
- % Faculty of Computational Mathematics
- % and Computer Science,
- % System Analysis Department 2013 $
- methods (Access = public)
- function self = StrucdispTC(varargin)
- self = se...@mlunitext.test_case(varargin{:});
- end
-
- function self = testArrays(self)
- S = struct('a', 1);
- str = evalc('strucdisp(S)');
- isOk = ~isempty(strfind(str, '1'));
-
- S = struct('a', [1 2 3]);
- str = evalc('strucdisp(S)');
- isOk = isOk & ~isempty(strfind(str, '[1 2 3]'));
-
- S = struct('a', ones(5, 3, 2));
- str = evalc('strucdisp(S)');
- isOk = isOk & ~isempty(strfind(str, '[5x3x2 Array]'));
-
- mlunitext.assert_equals(isOk, true);
- end
-
- function self = testLogicalFields(self)
- S = struct('a', false(1, 2));
- str = evalc('strucdisp(S)');
- isOk = ~isempty(strfind(str, '[false false]'));
-
- S = struct('a', false);
- str = evalc('strucdisp(S)');
- isOk = isOk & ~isempty(strfind(str, 'false'));
-
- S = struct('a', false(5));
- str = evalc('strucdisp(S)');
- isOk = isOk & ~isempty(strfind(str, '[5x5 Logic array]'));
-
- mlunitext.assert_equals(isOk, true);
- end
- end
-end
=======================================
--- /branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/isempty.m
Sat May 4 22:48:37 2013
+++ /dev/null
@@ -1,35 +0,0 @@
-function isPositiveArr = isempty(myHypArr)
-%
-% ISEMPTY - checks if hyperplanes in H are empty.
-%
-% Input:
-% regular:
-% myHypArr: hyperplane [nDims1, nDims2, ...] - array
-% of hyperplanes.
-%
-% Output:
-% isPositiveArr: logical[nDims1, nDims2, ...],
-% isPositiveArr(iDim1, iDim2, ...) = true - if ellipsoid
-% myHypArr(iDim1, iDim2, ...) is empty, false - otherwise.
-%
-% Example:
-% hypObj = hyperplane();
-% isempty(hypObj)
-%
-% ans =
-%
-% 1
-%
-% $Author: Alex Kurzhanskiy <
akur...@eecs.berkeley.edu>
-% $Copyright: The Regents of the University of California
-% 2004-2008 $
-%
-% $Author: Aushkap Nikolay <
n.au...@gmail.com> $
-% $Date: 30-11-2012$
-% $Copyright: Moscow State University,
-% Faculty of Computational Mathematics
-% and Computer Science,
-% System Analysis Department 2012 $
-
-hyperplane.checkIsMe(myHypArr);
-isPositiveArr = (dimension(myHypArr) == 0);
=======================================
--- /branches/issue_66_akarev/lib/+modgen/+struct/+test/run_tests.m Sat May
18 00:16:26 2013
+++ /branches/issue_66_akarev/lib/+modgen/+struct/+test/run_tests.m Tue Jun
18 13:33:55 2013
@@ -6,7 +6,7 @@
'modgen.struct.test.mlunit_test_structcompare');
%
suite_mixed = loader.load_tests_from_test_case(...
- 'modgen.struct.test.mlunit_test_mixed');
+ 'modgen.struct.test.StructDispTC');
%
suite = mlunitext.test_suite(horzcat(...
suite.tests,suite_mixed.tests));
=======================================
--- /branches/issue_66_akarev/lib/NoPkg/StructCell/strucdisp.m Sun May 19
19:36:54 2013
+++ /branches/issue_66_akarev/lib/NoPkg/StructCell/strucdisp.m Tue Jun 18
13:33:55 2013
@@ -42,7 +42,7 @@
% used
%
%
-% $Author: Peter Gagarinov <
pgaga...@gmail.com> $ $Date: 2011-12-08 $
+% $Author: Peter Gagarinov <
pgaga...@gmail.com> $ $Date: 2011-12-08 $
% $Copyright: Moscow State University,
% Faculty of Computational Mathematics and Computer Science,
% System Analysis Department 2011 $
@@ -135,8 +135,8 @@
if (~isvector(Structure))
indexStr = [structureName, '('];
for iDimension = 1 : length(sizeVec) - 1
- indexStr = [indexStr, sprintf('%d, ',...
- indexVec(iDimension))];
+ indexStr = [indexStr, sprintf('%d, ',...
+ indexVec(iDimension))];
end
indexStr = [indexStr, sprintf('%d)',
indexVec(end))];
indexVec = incrementIndexVec(indexVec, sizeVec);
@@ -348,8 +348,8 @@
* DASH_SYMBOL_CODE);
if (size(Structure.(Field), 1) > 1) &&
(size(Structure.(Field), 2) > 1)
varStr = createArraySize(Structure.(Field), 'char');
-% elseif length(Field) > maxStrLength
-% varStr = sprintf(' ''%s...''',
Structure.(Field(1:maxStrLength)));
+ % elseif length(Field) > maxStrLength
+ % varStr = sprintf(' ''%s...''',
Structure.(Field(1:maxStrLength)));
else
varStr = sprintf(' ''%s''', Structure.(Field));
end
@@ -440,9 +440,9 @@
varStr = createArraySize(Structure.(Field), 'Array');
varCell = {[strIndent ' |' filler ' ' Field ' :'
varStr]};
else
-% matrixSize = size(Structure.(Field));
-% filler2 = char(ones(1, maxFieldLength + 6) *
FILLER_SYMBOL_CODE);
-% dashes = char(ones(1, 12 * matrixSize(2) + 1) *
DASH_SYMBOL_CODE);
+ % matrixSize = size(Structure.(Field));
+ % filler2 = char(ones(1, maxFieldLength +
6) * FILLER_SYMBOL_CODE);
+ % dashes = char(ones(1, 12 * matrixSize(2)
+ 1) * DASH_SYMBOL_CODE);
curPrintFormat=numberFormat;
printedFieldValue=cellfun(@(x)sprintf(curPrintFormat,x),...
num2cell(Structure.(Field)),'UniformOutput',false);
@@ -491,7 +491,7 @@
fieldValue,'UniformOutput',false);
nDashes=(maxStringLength+1)* matrixSize(2)+1;
filler2 = char(ones(1, maxFieldLength + 6) * FILLER_SYMBOL_CODE);
- dashes = char(ones(1, nDashes)* DASH_SYMBOL_CODE);
+ dashes = char(ones(1, nDashes)* DASH_SYMBOL_CODE);
varCell = {[strIndent ' |' filler2 dashes]};
%
% first line with field name
@@ -509,16 +509,16 @@
end
function newIndexVec = incrementIndexVec(indexVec, sizeVec)
- newIndexVec = indexVec;
- for iDimension = 1 : length(sizeVec)
- newIndexVec(iDimension) = newIndexVec(iDimension) + 1;
- if (newIndexVec(iDimension) <= sizeVec(iDimension))
- break;
- else
- newIndexVec(iDimension) = 1;
- end
+newIndexVec = indexVec;
+for iDimension = 1 : length(sizeVec)
+ newIndexVec(iDimension) = newIndexVec(iDimension) + 1;
+ if (newIndexVec(iDimension) <= sizeVec(iDimension))
+ break;
+ else
+ newIndexVec(iDimension) = 1;
end
end
+end
%% FUNCTION: getIndentation
% This function creates the hierarchical indentations
=======================================
---
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/ADispStructTC.m
Thu Jun 13 13:56:53 2013
+++
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/ADispStructTC.m
Tue Jun 18 13:33:55 2013
@@ -6,36 +6,84 @@
% Faculty of Computational Mathematics
% and Computer Science,
% System Analysis Department 2013 $
+ methods (Abstract, Static, Access = public)
+ getToStructObj(iTest)
+ getToStructStruct(iTest)
+ getToStructIsPropIncluded(iTest)
+ getToStructResult(iTest)
+ getFromStructObj(iTest)
+ getFromStructStruct(iTest)
+ getFromStructResult(iTest)
+ getDisplayObj(iTest)
+ getDisplayStrings(iTest)
+ getDisplayResult(iTest)
+ getEqFstObj(iTest)
+ getEqSndObj(iTest)
+ getEqResult(iTest)
+ end
methods (Access = public)
function self = ADispStructTC(varargin)
self = se...@mlunitext.test_case(varargin{:});
end
- function self = toStructTest(self, ObjArr, StructArr,...
+ function self = auxToStructTest(self, ObjArr, StructArr,...
isPropsIncluded, result)
SObtainedArr = ObjArr.toStruct(isPropsIncluded);
isOk = isequal(StructArr, SObtainedArr);
mlunitext.assert_equals(isOk, result);
end
- function self = displayTest(self, ObjArr, displayStringCVec,
result)
+ function self = auxDisplayTest(self, ObjArr,...
+ displayStringCVec, result)
obtainedStr = evalc('ObjArr.display()');
- isOk = true;
- for iString = 1 : numel(displayStringCVec)
- isOk = isOk & ~isempty(strfind(obtainedStr,
displayStringCVec{iString}));
- end
+ isOk = all(cellfun(@(Str1, Str2)~isempty(strfind(Str1,
Str2)), ...
+ repmat({obtainedStr}, size(displayStringCVec)),...
+ displayStringCVec));
mlunitext.assert_equals(isOk, result);
end
- function self = fromStructTest(self, StructArr, ObjArr, sampleObj,
result)
- obtainedObjArr = sampleObj.fromStruct(StructArr);
+ function self = auxFromStructTest(self, StructArr, ObjArr, result)
+ obtainedObjArr = ObjArr.fromStruct(StructArr);
isOk = isequal(ObjArr, obtainedObjArr);
mlunitext.assert_equals(isOk, result);
- end
+ end
- function self = eqTest(self, ObjArr1, ObjArr2, result)
+ function self = auxEqTest(self, ObjArr1, ObjArr2, result)
isOk = isequal(ObjArr1, ObjArr2);
mlunitext.assert_equals(isOk, result);
end
+
+ function self = testToStuct(self)
+ for iTest = 1 : 7
+ auxToStructTest(self, self.getToStructObj(iTest),...
+ self.getToStructStruct(iTest),...
+ self.getToStructIsPropIncluded(iTest),...
+ self.getToStructResult(iTest));
+ end
+ end
+
+ function self = testFromStruct(self)
+ for iTest = 1 : 6
+ auxFromStructTest(self, self.getFromStructStruct(iTest),...
+ self.getFromStructObj(iTest),...
+ self.getFromStructResult(iTest));
+ end
+ end
+
+ function self = testDisplay(self)
+ for iTest = 1 : 6
+ auxDisplayTest(self, self.getDisplayObj(iTest),...
+ self.getDisplayStrings(iTest),...
+ self.getDisplayResult(iTest));
+ end
+ end
+
+ function self = testEq(self)
+ for iTest = 1 : 6
+ auxEqTest(self, self.getEqFstObj(iTest),...
+ self.getEqSndObj(iTest),...
+ self.getEqResult(iTest));
+ end
+ end
end
end
=======================================
---
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/EllipsoidDispStructTC.m
Thu Jun 13 13:56:53 2013
+++
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/EllipsoidDispStructTC.m
Tue Jun 18 13:33:55 2013
@@ -6,115 +6,197 @@
% Faculty of Computational Mathematics
% and Computer Science,
% System Analysis Department 2013 $
- methods
+ methods (Static)
+ function objArr = getToStructObj(iTest)
+ switch iTest
+ case 2
+ objArr = ellipsoid();
+ case 6
+ objArr = ellipsoid.fromRepMat(1, 1, [5 5 5]);
+ case 7
+ objArr = ellipsoid.fromRepMat(1, 1, [5 5 5]);
+ objArr(1) = ellipsoid();
+ otherwise
+ objArr = ellipsoid([1, 1]', eye(2));
+ end
+ end
+
+ function SArr = getToStructStruct(iTest)
+ switch iTest
+ case 1
+ SArr = struct('shapeMat', eye(2), 'centerVec', [1,
1]');
+ case 2
+ SArr = struct('shapeMat', [], 'centerVec', []);
+ case 3
+ SArr = struct('shapeMat', [], 'centerVec', []);
+ case 4
+ SArr = struct('shapeMat', eye(2), 'centerVec', [1,
1]',...
+ 'absTol', 1e-7, 'relTol', 1e-5,...
+ 'nPlot2dPoints', 200, 'nPlot3dPoints', 200);
+ case 5
+ SArr = struct('shapeMat', eye(2), 'centerVec', [2,
1]');
+ case 6
+ SArr = struct('shapeMat', num2cell(ones(5, 5, 5)), ...
+ 'centerVec', num2cell(ones(5, 5, 5)));
+ case 7
+ SArr = struct('shapeMat', num2cell(ones(5, 5, 5)), ...
+ 'centerVec', num2cell(ones(5, 5, 5)));
+ end
+ end
+
+ function isProp = getToStructIsPropIncluded(iTest)
+ isProp = iTest == 4;
+ end
+
+ function result = getToStructResult(iTest)
+ falseAnswers = [3, 5, 7];
+ result = isempty(find(falseAnswers == iTest, 1));
+ end
+
+ function objArr = getFromStructObj(iTest)
+ switch iTest
+ case 1
+ objArr = ellipsoid([1, 1]', eye(2));
+ case 2
+ objArr = ellipsoid([1, 1]', eye(2), 'absTol', 1e-8,...
+ 'relTol', 1e-4, 'nPlot2dPoints', 300, ...
+ 'nPlot3dPoints', 100);
+ case 3
+ objArr = ellipsoid();
+ case 4
+ objArr = ellipsoid([1, 1]', eye(2));
+ case 5
+ objArr = ellipsoid.fromRepMat(1, 1, [5 5 5]);
+ case 6
+ objArr = ellipsoid.fromRepMat(1, 1, [5 5 5]);
+ objArr(1) = ellipsoid();
+ end
+ end
+
+ function SArr = getFromStructStruct(iTest)
+ switch iTest
+ case 1
+ SArr = struct('shapeMat', eye(2), 'centerVec', [1, 1]);
+ case 2
+ SArr = struct('shapeMat', eye(2), 'centerVec', [1,
1],...
+ 'absTol', 1e-8, 'relTol', 1e-4,...
+ 'nPlot2dPoints', 300, 'nPlot3dPoints', 100);
+ case 3
+ SArr = struct('shapeMat', eye(2), 'centerVec', [1,
1],...
+ 'absTol', 1e-8, 'relTol', 1e-4,...
+ 'nPlot2dPoints', 300, 'nPlot3dPoints', 100);
+ case 4
+ SArr = struct('shapeMat', eye(2), 'centerVec', [1,
1],...
+ 'absTol', 1e-8, 'relTol', 1e-4,...
+ 'nPlot2dPoints', 300, 'nPlot3dPoints', 100);
+ case 5
+ SArr = struct('shapeMat', num2cell(ones(5, 5, 5)),...
+ 'centerVec', num2cell(ones(5, 5, 5)));
+ case 6
+ SArr = struct('shapeMat', num2cell(ones(5, 5, 5)),...
+ 'centerVec', num2cell(ones(5, 5, 5)));
+ end
+ end
+
+ function result = getFromStructResult(iTest)
+ falseAnswers = [3, 4, 6];
+ result = isempty(find(falseAnswers == iTest, 1));
+ end
+
function self = EllipsoidDispStructTC(varargin)
self =
se...@elltool.core.test.mlunit.ADispStructTC(varargin{:});
end
- function self = testToStruct(self)
- ell = ellipsoid([1, 1]', eye(2));
- ellStruct = struct('shapeMat', eye(2), 'centerVec', [1, 1]);
- toStructTest(self, ell, ellStruct, false, true);
-
- ell2 = ellipsoid();
- ell2Struct = struct('shapeMat', [], 'centerVec', []);
- toStructTest(self, ell2, ell2Struct, false, true);
- toStructTest(self, ell, ell2Struct, false, false);
-
- ellStruct = struct('shapeMat', eye(2), 'centerVec', [1, 1],...
- 'absTol', 1e-7, 'relTol', 1e-5,...
- 'nPlot2dPoints', 200, 'nPlot3dPoints', 200);
- toStructTest(self, ell, ellStruct, true, true);
-
- ellStruct = struct('shapeMat', eye(2), 'centerVec', [2, 1]);
- toStructTest(self, ell, ellStruct, false, false);
-
- for iEll = 125 : -1 : 1
- ellArr(iEll) = ellipsoid(1, 1);
+ function objArr = getDisplayObj(iTest)
+ switch iTest
+ case 1
+ objArr = ellipsoid([1, 1]', eye(2));
+ case 2
+ objArr = ellipsoid();
+ case 3
+ objArr = ellipsoid([1, 2]', eye(2));
+ case 4
+ objArr = ellipsoid.fromStruct(struct('shapeMat',...
+ num2cell(ones(5, 5, 5)), ...
+ 'centerVec', num2cell(ones(5, 5, 5))));
+ case 5
+ objArr = ellipsoid.fromStruct(struct('shapeMat', ...
+ num2cell(ones(5, 5, 5)), ...
+ 'centerVec', num2cell(ones(5, 5, 5))));
+ objArr = [objArr, objArr];
+ case 6
+ objArr = hyperplane();
end
- ellArr = reshape(ellArr, [5 5 5]);
- ellArrStruct = struct('shapeMat', num2cell(ones(5, 5, 5)), ...
- 'centerVec', num2cell(ones(5, 5, 5)));
- toStructTest(self, ellArr, ellArrStruct, false, true);
- ellArr(1) = ellipsoid();
- toStructTest(self, ellArr, ellArrStruct, false, false);
+ end
+
+ function stringCVec = getDisplayStrings(iTest)
+ stringCVec = {'Ellipsoid shape matrix.', ...
+ 'ellipsoid object',...
+ 'centerVec',...
+ 'shapeMat'};
+ if (iTest > 4)
+ stringCVec = horzcat(stringCVec, 'ObjArr(1, 1, 1)');
+ end
+ end
+
+ function result = getDisplayResult(iTest)
+ result = iTest ~= 6;
end
- function self = testFromStruct(self)
- ell = ellipsoid([1, 1]', eye(2));
- ellStruct = struct('shapeMat', eye(2), 'centerVec', [1, 1]);
- fromStructTest(self, ellStruct, ell, ellipsoid(), true);
-
- ell2Struct = struct('shapeMat', eye(2), 'centerVec', [1, 1],...
- 'absTol', 1e-8, 'relTol', 1e-4,...
- 'nPlot2dPoints', 300, 'nPlot3dPoints', 100);
- ell2 = ellipsoid([1, 1]', eye(2), 'absTol', 1e-8,...
- 'relTol', 1e-4, 'nPlot2dPoints', 300, ...
- 'nPlot3dPoints', 100);
- fromStructTest(self, ell2Struct, ell2, ellipsoid(), true);
-
- ell3 = ellipsoid();
- fromStructTest(self, ell2Struct, ell3, ellipsoid(), false);
- fromStructTest(self, ell2Struct, ell, ellipsoid(), false);
-
- for iEll = 125 : -1 : 1
- ellArr(iEll) = ellipsoid(1, 1);
+ function objArr = getEqFstObj(iTest)
+ switch iTest
+ case 1
+ objArr = ellipsoid([1, 1]', eye(2));
+ case 2
+ objArr = ellipsoid();
+ case 3
+ objArr = ellipsoid([1, 2]', eye(2));
+ case 4
+ objArr = ellipsoid();
+ case 5
+ objArr = ellipsoid();
+ case 6
+ objArr = ellipsoid.fromStruct(struct('shapeMat',...
+ num2cell(ones(5, 5, 5)), ...
+ 'centerVec', num2cell(ones(5, 5, 5))));
+ case 7
+ objArr = ellipsoid.fromStruct(struct('shapeMat',...
+ num2cell(ones(5, 5, 5)), ...
+ 'centerVec', num2cell(ones(5, 5, 5))));
+ case 8
+ objArr = ellipsoid.fromRepMat([1, 1]', eye(2), [1 2]);
end
- ellArr = reshape(ellArr, [5 5 5]);
- ellArrStruct = struct('shapeMat', num2cell(ones(5, 5, 5)),...
- 'centerVec', num2cell(ones(5, 5, 5)));
- fromStructTest(self, ellArrStruct, ellArr, ellipsoid(), true);
- ellArr(1) = ellipsoid();
- fromStructTest(self, ellArrStruct, ellArr, ellipsoid(), false);
end
- function self = testDisplay(self)
- ell = ellipsoid([1, 1]', eye(2));
- patternsCVec = {'Ellipsoid shape matrix.', ...
- 'ellipsoid object',...
- 'centerVec',...
- 'shapeMat'};
- displayTest(self, ell, patternsCVec, true);
-
- ell = ellipsoid();
- displayTest(self, ell, patternsCVec, true);
-
- ell = ellipsoid([1, 2]', eye(2));
- displayTest(self, ell, patternsCVec, true);
-
- ellArr = ellipsoid.fromStruct(struct('shapeMat',
num2cell(ones(5, 5, 5)), ...
- 'centerVec', num2cell(ones(5, 5, 5))));
- displayTest(self, ellArr, patternsCVec, true);
-
- ell = [ell, ell];
- patternsCVec = horzcat(patternsCVec, 'ObjArr(1)');
- displayTest(self, ell, patternsCVec, true);
- hp = hyperplane();
- displayTest(self, hp, patternsCVec, false);
+ function objArr = getEqSndObj(iTest)
+ switch iTest
+ case 1
+ objArr = ellipsoid([1, 1]', eye(2));
+ case 2
+ objArr = ellipsoid();
+ case 3
+ objArr = ellipsoid([1, 2]', eye(2));
+ case 4
+ objArr = ellipsoid([1, 2]', eye(2));
+ case 5
+ objArr = ellipsoid([1, 1]', eye(2));
+ case 6
+ objArr = ellipsoid.fromStruct(struct('shapeMat',...
+ num2cell(ones(5, 5, 5)), ...
+ 'centerVec', num2cell(ones(5, 5, 5))));
+ case 7
+ objArr = ellipsoid.fromStruct(struct('shapeMat',...
+ num2cell(ones(5, 5, 5)), ...
+ 'centerVec', num2cell(ones(5, 5, 5))));
+ objArr(1, 1, 1) = ellipsoid();
+ case 8
+ objArr = ellipsoid.fromRepMat([1, 1]', eye(2), [1 2]);
+ end
end
- function self = testEq(self)
- ell = ellipsoid([1, 1]', eye(2));
- eqTest(self, ell, ell, true);
-
- ell2 = ellipsoid();
- eqTest(self, ell2, ell2, true);
-
- ell3 = ellipsoid([1, 2]', eye(2));
- eqTest(self, ell3, ell3, true);
- eqTest(self, ell2, ell3, false);
- eqTest(self, ell2, ell, false);
-
- ellArr = ellipsoid.fromStruct(struct('shapeMat',
num2cell(ones(5, 5, 5)), ...
- 'centerVec', num2cell(ones(5, 5,
5))));
- eqTest(self, ellArr, ellArr, true);
- ellArr2 = ellArr;
- ellArr2(1, 1, 1) = ellipsoid();
- eqTest(self, ellArr, ellArr2, false);
-
- ell = [ell ell];
- eqTest(self, ell, ell, true);
- eqTest(self, ell, ellArr2(1, 1:2, 1), false);
+ function result = getEqResult(iTest)
+ falseAnswers = [4, 5, 7];
+ result = isempty(find(falseAnswers == iTest, 1));
end
end
end
=======================================
---
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/EllipsoidTestCase.m
Thu Jun 13 13:56:53 2013
+++
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/EllipsoidTestCase.m
Tue Jun 18 13:33:55 2013
@@ -925,11 +925,11 @@
checkEllEqual(testEllipsoid3, testEllipsoid2, false, ...
'(1).Q-->Max. difference (4.142136e-01) is greater than
the specified tolerance(1.000000e-05)');
- ansStr = sprintf('(1).Q-->Different sizes (left: [2 2], right:
[3 3])\n(1).q-->Different sizes (left: [1 2], right: [1 3])');
+ ansStr = sprintf('(1).Q-->Different sizes (left: [2 2], right:
[3 3])\n(1).q-->Different sizes (left: [2 1], right: [3 1])');
checkEllEqual(testEllipsoidZeros2, testEllipsoidZeros3, false,
ansStr);
- ansStr = sprintf('(1).Q-->Different sizes (left: [2 2], right:
[0 0])\n(1).q-->Different sizes (left: [1 2], right: [0 0])');
+ ansStr = sprintf('(1).Q-->Different sizes (left: [2 2], right:
[0 0])\n(1).q-->Different sizes (left: [2 1], right: [0 0])');
checkEllEqual(testEllipsoidZeros2, testEllipsoidEmpty, false,
ansStr);
@@ -944,8 +944,8 @@
- ansStr = sprintf('(1).Q-->Different sizes (left: [2 2], right:
[3 3])\n(1).q-->Different sizes (left: [1 2], right: [1 3])');
- checkEllEqual([testEllipsoidZeros2 testEllipsoidZeros3],
[testEllipsoidZeros3 testEllipsoidZeros3], [false, true], ansStr);
+ ansStr = sprintf('(1).Q-->Different sizes (left: [2 2], right:
[3 3])\n(1).q-->Different sizes (left: [2 1], right: [3 1])');
+ checkEllEqual([testEllipsoidZeros2 testEllipsoidZeros3],
[testEllipsoidZeros3 testEllipsoidZeros3], [false, true], ansStr);
end
%
function self = testNe(self)
@@ -1379,16 +1379,16 @@
end
%
function self = testToStruct(self)
- centerCVec{1} = [1 2 3]';
+ centerCVec{1} = [1 2 3];
shapeMatCVec{1} = eye(3);
- centerCVec{2} = [2 3 4]';
+ centerCVec{2} = [2 3 4];
shapeMatCVec{2} = ones(3);
- centerCVec{3} = [1 0]';
+ centerCVec{3} = [1 0];
shapeMatCVec{3} = [3 1; 1 2];
- centerCVec{4} = [1 0 0 0]';
+ centerCVec{4} = [1 0 0 0];
shapeMatCVec{4} = diag([3 2 1 0]);
for iElem = 1 : 4
- ellVec(iElem) = ellipsoid(centerCVec{iElem},
shapeMatCVec{iElem});
+ ellVec(iElem) = ellipsoid(centerCVec{iElem}',
shapeMatCVec{iElem});
transposedCenterCVec{iElem} = centerCVec{iElem}';
end
SEllVec = struct('centerVec',
transposedCenterCVec, 'shapeMat', shapeMatCVec);
=======================================
---
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/HyperplaneDispStructTC.m
Thu Jun 13 13:56:53 2013
+++
/branches/issue_66_akarev/products/+elltool/+core/+test/+mlunit/HyperplaneDispStructTC.m
Tue Jun 18 13:33:55 2013
@@ -6,117 +6,204 @@
% Faculty of Computational Mathematics
% and Computer Science,
% System Analysis Department 2013 $
- methods
- function self = HyperplaneDispStructTC(varargin)
- self =
se...@elltool.core.test.mlunit.ADispStructTC(varargin{:});
+ methods (Static)
+ function objArr = getToStructObj(iTest)
+ switch iTest
+ case 1
+ objArr = hyperplane([1, 1, 2]', 3);
+ case 2
+ objArr = hyperplane();
+ case 3
+ objArr = hyperplane([1, 1, 2]', 3);
+ case 4
+ objArr = hyperplane([1, 1, 2]', 3);
+ case 5
+ objArr = hyperplane([1, 1, 2]', 2);
+ case 6
+ objArr = hyperplane.fromRepMat(1, 1, [5 5 5]);
+ case 7
+ objArr = hyperplane.fromRepMat(1, 1, [5 5 5]);
+ objArr(1) = hyperplane();
+ end
end
- function self = testToStruct(self)
- hp = hyperplane([1, 1, 2]', 3);
- hpStruct = struct('normal', [1, 1, 2]', 'shift', 3);
- hpStruct.shift = hpStruct.shift/norm(hpStruct.normal);
- hpStruct.normal = hpStruct.normal/norm(hpStruct.normal);
- toStructTest(self, hp, hpStruct, false, true);
-
- hp2 = hyperplane();
- hp2Struct = struct('normal', [], 'shift', []);
- toStructTest(self, hp2, hp2Struct, false, true);
- toStructTest(self, hp, hp2Struct, false, false);
-
- hpStruct = struct('normal', [1, 1, 2]', 'shift', 3, 'absTol',
1e-7);
- hpStruct.shift = hpStruct.shift/norm(hpStruct.normal);
- hpStruct.normal = hpStruct.normal/norm(hpStruct.normal);
- toStructTest(self, hp, hpStruct, true, true);
-
- hp = hyperplane([1, 1, 2]', 2);
- toStructTest(self, hp, hpStruct, false, false);
-
- for iHp = 125 : -1 : 1
- hpArr(iHp) = hyperplane(1, 1);
+ function SArr = getToStructStruct(iTest)
+ switch iTest
+ case 1
+ SArr = struct('normal', [1, 1, 2]', 'shift', 3);
+ SArr.shift = SArr.shift/norm(SArr.normal);
+ SArr.normal = SArr.normal/norm(SArr.normal);
+ case 2
+ SArr = struct('normal', [], 'shift', []);
+ case 3
+ SArr = struct('normal', [], 'shift', []);
+ case 4
+ SArr = struct('normal', [1, 1, 2]', 'shift',...
+ 3, 'absTol', 1e-7);
+ SArr.shift = SArr.shift/norm(SArr.normal);
+ SArr.normal = SArr.normal/norm(SArr.normal);
+ case 5
+ SArr = struct('normal', [1, 1, 2]', 'shift', ...
+ 3, 'absTol', 1e-7);
+ SArr.shift = SArr.shift/norm(SArr.normal);
+ SArr.normal = SArr.normal/norm(SArr.normal);
+ case 6
+ SArr = struct('normal', num2cell(ones(5, 5, 5)), ...
+ 'shift', num2cell(ones(5, 5, 5)));
+ case 7
+ SArr = struct('normal', num2cell(ones(5, 5, 5)), ...
+ 'shift', num2cell(ones(5, 5, 5)));
+ end
+ end
+
+ function isProps = getToStructIsPropIncluded(iTest)
+ isProps = iTest == 4;
+ end
+
+ function result = getToStructResult(iTest)
+ falseAnswers = [3, 5, 7];
+ result = isempty(find(falseAnswers == iTest, 1));
+ end
+
+ function objArr = getFromStructObj(iTest)
+ switch iTest
+ case 1
+ objArr = hyperplane([1, 2]', 3);
+ case 2
+ objArr = hyperplane([1, 2]', 3);
+ case 3
+ objArr = hyperplane();
+ case 4
+ objArr = hyperplane([1, 2]', 3);
+ case 5
+ objArr = hyperplane.fromRepMat(1, 1, [5 5 5]);
+ case 6
+ objArr = hyperplane.fromRepMat(1, 1, [5 5 5]);
+ objArr(1) = hyperplane();
+ end
+ end
+
+ function SArr = getFromStructStruct(iTest)
+ switch iTest
+ case 1
+ SArr = struct('normal', [1, 2]', 'shift', 3);
+ case 2
+ SArr = struct('normal', [1, 2]', 'shift', 3);
+ case 3
+ SArr = struct('normal', [1, 2]', 'shift', 3,...
+ 'absTol', 1e-5);
+ case 4
+ SArr = struct('normal', [1, 2]', 'shift', 3,...
+ 'absTol', 1e-5);
+ case 5
+ SArr = struct('normal', num2cell(ones(5, 5, 5)), ...
+ 'shift', num2cell(ones(5, 5, 5)));
+ case 6
+ SArr = struct('normal', num2cell(ones(5, 5, 5)), ...
+ 'shift', num2cell(ones(5, 5, 5)));
+ end
+ end
+
+ function result = getFromStructResult(iTest)
+ falseAnswers = [3, 4, 6];
+ result = isempty(find(falseAnswers == iTest, 1));
+ end
+
+ function objArr = getDisplayObj(iTest)
+ switch iTest
+ case 1
+ objArr = hyperplane([1, 2]', 3);
+ case 2
+ objArr = hyperplane();
+ case 3
+ objArr = hyperplane([1, 1]', 3);
+ case 4
+ objArr = hyperplane.fromStruct(struct('normal',...
+ num2cell(ones(5, 5, 5)), ...
+ 'shift', num2cell(ones(5, 5, 5))));
+ case 5
+ objArr = hyperplane([1, 2]', 3);
+ objArr = [objArr objArr];
+ case 6
+ objArr = ellipsoid();
+ end
+ end
+
+ function stringsCVec = getDisplayStrings(iTest)
+ stringsCVec = {'hyperplane object', ...
+ 'Properties',...
+ 'shift',...
+ 'normal',...
+ 'Hyperplane shift'};
+ if (iTest > 4)
+ stringsCVec = horzcat(stringsCVec, 'ObjArr(1)');
+ end
+ end
+
+ function result = getDisplayResult(iTest)
+ result = iTest ~= 6;
+ end
+
+ function objArr = getEqFstObj(iTest)
+ switch iTest
+ case 1
+ objArr = hyperplane([1, 2]', 3);
+ case 2
+ objArr = hyperplane();
+ case 3
+ objArr = hyperplane([1, 1]', 3);
+ case 4
+ objArr = hyperplane([1, 2]', 3);
+ case 5
+ objArr = hyperplane([1, 2]', 3);
+ case 6
+ objArr = hyperplane.fromStruct(struct('normal',...
+ num2cell(ones(5, 5, 5)), ...
+ 'shift', num2cell(ones(5, 5, 5))));
+ case 7
+ objArr = hyperplane.fromStruct(struct('normal',...
+ num2cell(ones(5, 5, 5)), ...
+ 'shift', num2cell(ones(5, 5, 5))));
+ case 8
+ objArr = hyperplane([1, 2]', 3);
+ objArr = [objArr objArr];
end
- hpArr = reshape(hpArr, [5 5 5]);
- hpArrStruct = struct('normal', num2cell(ones(5, 5, 5)), ...
- 'shift', num2cell(ones(5, 5, 5)));
- toStructTest(self, hpArr, hpArrStruct, false, true);
- hpArr(1) = hyperplane();
- toStructTest(self, hpArr, hpArrStruct, false, false);
end
- function self = testFromStruct(self)
- hp = hyperplane([1, 2]', 3);
- hpStruct = struct('normal', [1, 2]', 'shift', 3);
- fromStructTest(self, hpStruct, hp, hyperplane(), true);
-
- hp2Struct = struct('normal', [1, 2]', 'shift', 3,...
- 'absTol', 1e-5);
- hp2 = hyperplane([1, 2]', 3, 'absTol', 1e-5);
- fromStructTest(self, hpStruct, hp, hyperplane(), true);
-
- hp3 = hyperplane();
- fromStructTest(self, hp2Struct, hp3, hyperplane(), false);
- fromStructTest(self, hp2Struct, hp, hyperplane(), false);
-
- for iHp = 125 : -1 : 1
- hpArr(iHp) = hyperplane(1, 1);
+ function objArr = getEqSndObj(iTest)
+ switch iTest
+ case 1
+ objArr = hyperplane([1, 2]', 3);
+ case 2
+ objArr = hyperplane();
+ case 3
+ objArr = hyperplane([1, 1]', 3);
+ case 4
+ objArr = hyperplane([1, 1]', 3);
+ case 5
+ objArr = hyperplane();
+ case 6
+ objArr = hyperplane.fromStruct(struct('normal',...
+ num2cell(ones(5, 5, 5)), ...
+ 'shift', num2cell(ones(5, 5, 5))));
+ case 7
+ objArr = hyperplane.fromStruct(struct('normal',...
+ num2cell(ones(5, 5, 5)), ...
+ 'shift', num2cell(ones(5, 5, 5))));
+ objArr(1) = hyperplane();
+ case 8
+ objArr = hyperplane([1, 2]', 3);
+ objArr = [objArr objArr];
end
- hpArr = reshape(hpArr, [5 5 5]);
- hpArrStruct = struct('normal', num2cell(ones(5, 5, 5)), ...
- 'shift', num2cell(ones(5, 5, 5)));
- fromStructTest(self, hpArrStruct, hpArr, hyperplane(), true);
- hpArr(1) = hyperplane();
- fromStructTest(self, hpArrStruct, hpArr, hyperplane(), false);
-
end
- function self = testDisplay(self)
- hp = hyperplane([1, 2]', 3);
- patternsCVec = {'hyperplane object', ...
- 'Properties',...
- 'shift',...
- 'normal',...
- 'Hyperplane shift'};
- displayTest(self, hp, patternsCVec, true);
-
- hp = hyperplane();
- displayTest(self, hp, patternsCVec, true);
-
- hp = hyperplane([1, 1]', 3);
- displayTest(self, hp, patternsCVec, true);
-
- hpArr = hyperplane.fromStruct(struct('normal',
num2cell(ones(5, 5, 5)), ...
- 'shift', num2cell(ones(5, 5,
5))));
- displayTest(self, hpArr, patternsCVec, true);
-
- hp = [hp hp];
- patternsCVec = horzcat(patternsCVec, 'ObjArr(1)');
- displayTest(self, hp, patternsCVec, true);
-
- ell = ellipsoid();
- displayTest(self, ell, patternsCVec, false);
+ function result = getEqResult(iTest)
+ falseAnswers = [4, 5, 7];
+ result = isempty(find(falseAnswers == iTest, 1));
end
- function self = testEq(self)
- hp = hyperplane([1, 2]', 3);
- eqTest(self, hp, hp, true);
-
- hp2 = hyperplane();
- eqTest(self, hp, hp, true);
-
- hp3 = hyperplane([1, 1]', 3);
- eqTest(self, hp3, hp3, true);
- eqTest(self, hp, hp3, false);
- eqTest(self, hp, hp2, false);
-
- hpArr = hyperplane.fromStruct(struct('normal',
num2cell(ones(5, 5, 5)), ...
- 'shift', num2cell(ones(5, 5,
5))));
- eqTest(self, hpArr, hpArr, true);
- hpArr2 = hpArr;
- hpArr2(1, 1, 1) = hyperplane();
- eqTest(self, hpArr, hpArr2, false);
-
- hp = [hp hp];
- eqTest(self, hp, hp, true);
- eqTest(self, hp, hpArr2(1, 1:2, 1), false);
+ function self = HyperplaneDispStructTC(varargin)
+ self =
se...@elltool.core.test.mlunit.ADispStructTC(varargin{:});
end
end
end
=======================================
--- /branches/issue_66_akarev/products/+elltool/+core/+test/run_tests.m Thu
Jun 13 13:56:53 2013
+++ /branches/issue_66_akarev/products/+elltool/+core/+test/run_tests.m Tue
Jun 18 13:33:55 2013
@@ -17,7 +17,6 @@
'elltool.core.test.mlunit.EllipsoidMinkPlotTestCase',...
'elltool.core.test.mlunit.EllipsoidBasicSecondTC',...
'elltool.core.test.mlunit.EllipsoidDispStructTC',...
- 'elltool.core.test.mlunit.HyperplaneDispStructTC',...
- 'elltool.core.test.mlunit.StrucdispTC'}, varargin);
+ 'elltool.core.test.mlunit.HyperplaneDispStructTC'}, varargin);
%
result=runner.run(suite);
=======================================
--- /branches/issue_66_akarev/products/elltoolboxcore/@ellipsoid/eq.m Thu
Jun 13 13:56:53 2013
+++ /branches/issue_66_akarev/products/elltoolboxcore/@ellipsoid/eq.m Tue
Jun 18 13:33:55 2013
@@ -15,21 +15,21 @@
% results
%
% reportStr: char[1,] - comparison report
-%
+%
% Example:
% ellObj = ellipsoid([-2; -1], [4 -1; -1 1]);
% ellObj == [ellObj ellipsoid(eye(2))]
-%
+%
% ans =
-%
+%
% 1 0
%
-% $Author: Vadim Kaushansky <
vkaush...@gmail.com> $
+% $Author: Vadim Kaushansky <
vkaush...@gmail.com> $
% $Date: Nov-2012 $
% $Copyright: Moscow State University,
% Faculty of Computational Mathematics and Computer Science,
% System Analysis Department 2012 $
-% $Author: Peter Gagarinov <
pgaga...@gmail.com> $
+% $Author: Peter Gagarinov <
pgaga...@gmail.com> $
% $Date: Dec-2012 $
% $Copyright: Moscow State University,
% Faculty of Computational Mathematics and Computer Science,
@@ -53,7 +53,7 @@
modgen.common.checkvar( ellSecArr, 'numel(x) > 0', 'errorTag', ...
'wrongInput:emptyArray', 'errorMessage', ...
'Each array must be not empty.');
-[~, ABS_TOL] = ellFirstArr.getAbsTol;
+[~, absTol] = ellFirstArr.getAbsTol;
firstSizeVec = size(ellFirstArr);
secSizeVec = size(ellSecArr);
isnFirstScalar=nFirstElems > 1;
@@ -63,9 +63,9 @@
tolerance = relTol;
else
modgen.common.checkvar( varargin{1}, ...
- 'isa(x,''double'') && (numel(x) == 1)', 'errorTag', ...
- 'wrongInput:maxTolerance', 'errorMessage', ...
- 'Tolerance must be scalar double.');
+ 'isa(x,''double'') && (numel(x) == 1)', 'errorTag', ...
+ 'wrongInput:maxTolerance', 'errorMessage', ...
+ 'Tolerance must be scalar double.');
tolerance = varargin{1};
end
%
@@ -99,7 +99,7 @@
function SComp = formCompStruct(SEll)
- SComp.(SFieldNiceNames.shapeMat) = gras.la.sqrtmpos(SEll.shapeMat,
ABS_TOL);
+ SComp.(SFieldNiceNames.shapeMat) = gras.la.sqrtmpos(SEll.shapeMat,
absTol);
SComp.(SFieldNiceNames.centerVec) = SEll.centerVec;
end
end
=======================================
--- /branches/issue_66_akarev/products/elltoolboxcore/@ellipsoid/toStruct.m
Thu Jun 13 13:56:53 2013
+++ /branches/issue_66_akarev/products/elltoolboxcore/@ellipsoid/toStruct.m
Tue Jun 18 13:33:55 2013
@@ -55,7 +55,7 @@
end
function SEll = ell2Struct(ellObj, isPropIncluded)
-SEll = struct('shapeMat', ellObj.shapeMat, 'centerVec',
ellObj.centerVec.');
+SEll = struct('shapeMat', ellObj.shapeMat, 'centerVec', ellObj.centerVec);
if (isPropIncluded)
SEll.absTol = ellObj.absTol;
SEll.relTol = ellObj.relTol;
=======================================
---
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/hyperplane.m
Tue May 28 19:37:50 2013
+++
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/hyperplane.m
Tue Jun 18 13:33:55 2013
@@ -107,14 +107,14 @@
% hypObj = hyperplane(hypNormMat, hypConstVec);
%
% $Author: Alex Kurzhanskiy <
akur...@eecs.berkeley.edu>
- % $Copyright: The Regents of the University of California
+ % $Copyright: The Regents of the University of California
% 2004-2008 $
%
% $Author: Aushkap Nikolay <
n.au...@gmail.com> $
% $Date: 30-11-2012$
% $Copyright: Moscow State University,
% Faculty of Computational Mathematics
- % and Computer Science,
+ % and Computer Science,
% System Analysis Department 2012 $
import modgen.common.checkvar;
@@ -220,6 +220,7 @@
end
methods (Static)
checkIsMe(someObj)
+ hpArr = fromRepMat(varargin)
hpObj = fromStruct(SHpObj)
end
end
=======================================
---
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/toStruct.m
Thu Jun 13 13:56:53 2013
+++
/branches/issue_66_akarev/products/elltoolboxcore/@hyperplane/toStruct.m
Tue Jun 18 13:33:55 2013
@@ -43,21 +43,20 @@
end
function SHp = hp2Struct(hpObj, isPropIncluded)
-if (hpObj.isempty())
+if (hpObj.isEmpty())
SHp = struct('normal', [], 'shift', []);
- return;
-end
-
-[hpNormVec, hpScal] = parameters(hpObj);
-normMult = 1/norm(hpNormVec);
-hpNormVec = hpNormVec*normMult;
-hpScal = hpScal*normMult;
-if hpScal < 0
- hpScal = -hpScal;
- hpNormVec = -hpNormVec;
-end
-SHp = struct('normal', hpNormVec, 'shift', hpScal);
-if (isPropIncluded)
- SHp.absTol = hpObj.absTol;
+else
+ [hpNormVec, hpScal] = parameters(hpObj);
+ normMult = 1/norm(hpNormVec);
+ hpNormVec = hpNormVec*normMult;
+ hpScal = hpScal*normMult;
+ if hpScal < 0
+ hpScal = -hpScal;
+ hpNormVec = -hpNormVec;
+ end
+ SHp = struct('normal', hpNormVec, 'shift', hpScal);
+ if (isPropIncluded)
+ SHp.absTol = hpObj.absTol;
+ end
end
end