Skip to content

Commit

Permalink
Issue #42: BugFix & Enhancement
Browse files Browse the repository at this point in the history
- cosmetic and structured problems fixed
- some small bugs fixed
  • Loading branch information
alextim27 committed Dec 26, 2015
1 parent 9fe26db commit 3037176
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 183 deletions.
2 changes: 1 addition & 1 deletion products/+elltool/+core/+test/+mlunit/EllipsoidTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ function checkPropElem(ell)
0.255693118460086 - 0.343438979993794i];
testEllipsoid3 = ellipsoid(diag(1:1:4));
resEll = mtimes(AMat, testEllipsoid3);
ansEll = ellipsoid(zeros(4, 1), AMat*diag(1:1:4)*AMat.');
ansEll = ellipsoid(zeros(4, 1), AMat*diag(1:1:4)*AMat');
[isEq, reportStr] = isEqual(resEll, ansEll);
mlunitext.assert_equals(true, isEq, reportStr);

Expand Down
4 changes: 2 additions & 2 deletions products/+elltool/+core/@ABasicEllipsoid/formCompStruct.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
if isempty(SEll.(fieldName))
SComp.(SFieldNiceNames.(fieldName))=[];
else
fTransfomr=SFieldTransformFunc.(fieldName);
SComp.(SFieldNiceNames.(fieldName))=fTransfomr(SEll.(fieldName));
fTransform=SFieldTransformFunc.(fieldName);
SComp.(SFieldNiceNames.(fieldName))=fTransform(SEll.(fieldName));
end
end
end
3 changes: 2 additions & 1 deletion products/+elltool/+core/@ABasicEllipsoid/repMat.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
'errorMessage','size vector must have at least two elements')
checkvar(sizeVec,@(x)all(mod(x(:),1)==0)&&all(x(:)>=0)...
&&(size(x,1)==1),'errorTag','wrongInput', ...
'errorMessage','size vector must contain positive integer values.');
'errorMessage',...
'size vector must contain non-negative integer values.');
%
nEllipsoids=prod(sizeVec);
ellArr(1:nEllipsoids)=feval(class(ellObj));
Expand Down
8 changes: 5 additions & 3 deletions products/+elltool/+core/@AEllipsoid/AEllipsoid.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ellArr=shape(ellArr, modMat)
end
methods(Access=protected)
volVal=ellSingleVolume(ellObj)

end
methods(Abstract)
shapeMat=getShapeMat(self)
Expand All @@ -28,14 +28,16 @@
polar=getScalarPolarInternal(self,isRobustMethod)
end
methods(Abstract,Access=protected)
ellObj=changeShapeMatInternal(ellObj,isModScal,modMat)
fSingleProjection(ellObj,ortBasisMat)
ellObj=shapeSingleInternal(ellObj,isModScal,modMat)
projectionSingleInternal(ellObj,ortBasisMat)
end
methods(Abstract, Static)
ellArr=fromRepMat(varargin)
ellArr=fromStruct(SEllArr)
end
methods
isPositiveArr=isdegenerate(myEllArr)
volVal=volume(ellArr)
[dimArr,rankArr]=dimension(myEllArr)
outEllArr=getShape(ellArr,modMat)
minEigArr=mineig(inpEllArr)
Expand Down
58 changes: 0 additions & 58 deletions products/+elltool/+core/@AEllipsoid/ellSingleVolume.m

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
function isPositiveArr = isdegenerate(myEllArr)
%
% ISDEGENERATE - checks if the ellipsoid is degenerate.
%
% Input:
% regular:
% myEllArr: ellipsoid[nDims1,nDims2,...,nDimsN] - array of ellipsoids.
%
% Output:
% isPositiveArr: logical[nDims1,nDims2,...,nDimsN],
% isPositiveArr(iCount) = true if ellipsoid myEllMat(iCount)
% is degenerate, false - otherwise.
%
% Example:
% ellObj = ellipsoid([1; 1], eye(2));
% isdegenerate(ellObj)
%
% ans =
%
% 0
%
% $Author: Alex Kurzhanskiy <[email protected]>
% $Copyright: The Regents of the University of California
% 2004-2008 $
%
% $Author: Guliev Rustam <[email protected]> $
% $Date: Dec-2012$
% $Author: Peter Gagarinov <[email protected]> $ $Date: 25-04-2013$
% $Copyright: Moscow State University,
% Faculty of Computational Mathematics and Computer Science,
% System Analysis Department 2012 $
%
ellipsoid.checkIsMe(myEllArr);
modgen.common.checkvar(myEllArr,'~any(x(:).isEmpty())',...
'errorTag','wrongInput:emptyEllipsoid',...
'errorMessage','input argument contains empty ellipsoid.');
if isempty(myEllArr)
isPositiveArr = true(size(myEllArr));
else
isPositiveArr = ~arrayfun(@(x)gras.la.ismatposdef(x.shapeMat,x.absTol),...
myEllArr);
function isPositiveArr=isdegenerate(myEllArr)
%
% ISDEGENERATE - checks if the ellipsoid is degenerate.
%
% Input:
% regular:
% myEllArr: ellipsoid[nDims1,nDims2,...,nDimsN] - array of ellipsoids.
%
% Output:
% isPositiveArr: logical[nDims1,nDims2,...,nDimsN],
% isPositiveArr(iCount) = true if ellipsoid myEllMat(iCount)
% is degenerate, false - otherwise.
%
% Example:
% ellObj = ellipsoid([1; 1], eye(2));
% isdegenerate(ellObj)
%
% ans =
%
% 0
%
% $Author: Alex Kurzhanskiy <[email protected]>
% $Copyright: The Regents of the University of California
% 2004-2008 $
%
% $Author: Guliev Rustam <[email protected]> $
% $Date: Dec-2012$
% $Author: Peter Gagarinov <[email protected]> $ $Date: 25-04-2013$
% $Copyright: Moscow State University,
% Faculty of Computational Mathematics and Computer Science,
% System Analysis Department 2012 $
%
checkIsMeVirtual(myEllArr);
modgen.common.checkvar(myEllArr,'~any(x(:).isEmpty())',...
'errorTag','wrongInput:emptyEllipsoid',...
'errorMessage','input argument contains empty ellipsoid.');
if isempty(myEllArr)
isPositiveArr = true(size(myEllArr));
else
isPositiveArr = ~arrayfun(@(x)gras.la.ismatposdef(x.getShapeMat(),...
x.absTol),myEllArr);
end
2 changes: 1 addition & 1 deletion products/+elltool/+core/@AEllipsoid/mtimes.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
outEllArr=inpEllArr.getCopy();
arrayfun(@(x) fSingleMtimes(x),outEllArr);
function fSingleMtimes(ellObj)
ellObj.changeShapeMatInternal(isFstScal,multMat);
ellObj.shapeSingleInternal(isFstScal,multMat);
ellObj.centerVec=multMat*ellObj.getCenterVec();
end
end
2 changes: 1 addition & 1 deletion products/+elltool/+core/@AEllipsoid/projection.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@
normMat=repmat(realsqrt(normSqVec.'),nDim,1);
ortBasisMat=basisMat./normMat;
% compute projection
arrayfun(@(x)fSingleProjection(x,ortBasisMat),ellArr);
arrayfun(@(x)projectionSingleInternal(x,ortBasisMat),ellArr);
end
end
2 changes: 1 addition & 1 deletion products/+elltool/+core/@AEllipsoid/shape.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
3,nRows,nDim,dimArr,'errorMessage',...
'input matrix not square or dimensions do not match');
end
arrayfun(@(x)changeShapeMatInternal(x,isModScal,modMat),ellArr);
arrayfun(@(x)shapeSingleInternal(x,isModScal,modMat),ellArr);
end
58 changes: 58 additions & 0 deletions products/+elltool/+core/@AEllipsoid/volume.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function volArr=volume(ellArr)
%
% EllSINGLEVOLUME - returns the volume of the each AEllipsoid in array.
%
% volArr=VOLUME(ellArr) Computes the volume of AEllipsoids
%
%
% Input:
% regular:
% ellObj: AEllipsoid [nDims1,nDims2,...,nDimsN] - array
% of AEllipsoids.
%
% Output:
% volArr: double [nDims1,nDims2,...,nDimsN] - array of
% volume values, same size as ellObj.
%
% Example:
% firstEllObj=ellipsoid([4 -1; -1 1]);
% secEllObj=ell_unitball(2);
% ellVec=[firstEllObj secEllObj]
% volVec=ellVec.volume()
%
% volVec =
%
% 5.4414 3.1416
%
% $Author: Alex Kurzhanskiy <[email protected]>
% $Copyright: The Regents of the University of California
% 2004-2008 $
%
% $Author: Guliev Rustam <[email protected]> $
% $Date: Dec-2012$
% $Copyright: Moscow State University,
% Faculty of Computational Mathematics and Computer Science,
% System Analysis Department 2012 $
%
checkIsMeVirtual(ellArr);
modgen.common.checkvar(ellArr,'~any(x(:).isEmpty())',...
'errorTag','wrongInput:emptyEllipsoid',...
'errorMessage','input argument is empty.');
volArr=arrayfun(@(x) fSingleVolume(x), ellArr);
function volVal=fSingleVolume(ellObj)
if isdegenerate(ellObj)
volVal=0;
else
qMat=ellObj.getShapeMat();
nDim=ellObj.dimension();
if mod(nDim,2)
k=(nDim-1)*0.5;
s=((2^(2*k + 1))*(pi^k)*factorial(k))/factorial(2*k + 1);
else
k=nDim *0.5;
s=(pi^k)/factorial(k);
end
volVal=s*realsqrt(det(qMat));
end
end
end
4 changes: 2 additions & 2 deletions products/+elltool/+core/@GenEllipsoid/GenEllipsoid.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
checkIsMe(ellArr,varargin)
end
methods(Access=protected)
changeShapeMatInternal(ellObj,isModScal,modMat)
fSingleProjection(ellObj,ortBasisMat)
shapeSingleInternal(ellObj,isModScal,modMat)
projectionSingleInternal(ellObj,ortBasisMat)
function checkIsMeVirtual(ellArr,varargin)
elltool.core.GenEllipsoid.checkIsMe(ellArr,varargin)
end
Expand Down

This file was deleted.

17 changes: 8 additions & 9 deletions products/+elltool/+core/@GenEllipsoid/isdegenerate.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
modgen.common.checkvar(myEllArr,'~any(x(:).isEmpty())',...
'errorTag','wrongInput:emptyEllipsoid',...
'errorMessage','input argument contains empty GenEllipsoid.');
if isempty(myEllArr)
isPositiveArr=true(size(myEllArr));
else
isPositiveArr=~arrayfun(@(x)fIsSingleDegenerate(x),myEllArr);
isPositiveArr=true(size(myEllArr));
if ~isempty(myEllArr)
for iElem=1:numel(myEllArr)
qInfMat=myEllArr(iElem).getQInfMat();
isDegenerate=all(qInfMat(:)==0)&&...
[email protected](myEllArr(iElem));
isPositiveArr(iElem)=isDegenerate;
end
end
end
function isDegenerate=fIsSingleDegenerate(ellObj)
isDegenerate=...
gras.la.ismatnotdeg(ellObj.getShapeMat(),ellObj.getAbsTol())&&...
gras.la.ismatnotdeg(ellObj.getQInfMat(),ellObj.getAbsTol());
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function fSingleProjection(ellObj,ortBasisMat)
function projectionSingleInternal(ellObj,ortBasisMat)
ellObj.eigvMat=ortBasisMat'*ellObj.eigvMat;
ellObj.centerVec=ortBasisMat'*ellObj.centerVec;
end
4 changes: 4 additions & 0 deletions products/+elltool/+core/@GenEllipsoid/shapeSingleInternal.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function shapeSingleInternal(ellObj,isModScal,modMat) %#ok<INUSL>
eigvMat=modMat*ellObj.eigvMat;
ellObj.eigvMat=eigvMat;
end
19 changes: 7 additions & 12 deletions products/+elltool/+core/@GenEllipsoid/volume.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,14 @@
% Faculty of Computational Mathematics and Computer Science,
% System Analysis Department 2015 $
%
volArr = arrayfun(@(x) fSingleVolume(x), ellArr);
end
%
function volVal=fSingleVolume(ellObj)
qInfMat=ellObj.getQInfMat();
if any(qInfMat(:)>0)
volVal=Inf;
else
if ellObj.isEmpty()
simpleEllObj=ellipsoid();
elltool.core.GenEllipsoid.checkIsMe(ellArr);
volArr=zeros(size(ellArr));
for iElem=1:numel(ellArr)
qInfMat=ellArr(iElem).getQInfMat();
if any(qInfMat(:)>0)
volArr(iElem)=Inf;
else
simpleEllObj=ellipsoid(ellObj.centerVec,ellObj.getShapeMat());
volArr(iElem)[email protected](ellArr(iElem));
end
volVal=ellSingleVolume(simpleEllObj);
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function changeShapeMatInternal(ellObj,isModScal,modMat)
function shapeSingleInternal(ellObj,isModScal,modMat)
if isModScal
shMat=modMat*modMat*ellObj.getShapeMat();
else
Expand Down
5 changes: 2 additions & 3 deletions products/elltoolboxcore/@ellipsoid/ellipsoid.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
end
%
methods
volArr = volume(ellArr)
function resQuad = quadFunc(self)
% QUADFUNC computes quadratic function (x,Qx) of given
% ellipsoid.
Expand Down Expand Up @@ -279,8 +278,8 @@ function fMakeEllipsoid(iEll)
checkIsMe(ellArr,varargin)
end
methods (Access=protected)
changeShapeMatInternal(ellObj,isModScal,modMat)
fSingleProjection(ellObj,ortBasisMat)
shapeSingleInternal(ellObj,isModScal,modMat)
projectionSingleInternal(ellObj,ortBasisMat)
function checkIsMeVirtual(ellArr,varargin)
ellipsoid.checkIsMe(ellArr,varargin)
end
Expand Down
Loading

0 comments on commit 3037176

Please sign in to comment.