Skip to content

Commit

Permalink
Issue #42 Enhancement: function fromRepMat added
Browse files Browse the repository at this point in the history
  • Loading branch information
alextim27 committed Dec 7, 2015
1 parent 74a4c63 commit 0334b60
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions products/+elltool/+core/@GenEllipsoid/fromRepMat.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
function ellArr=fromRepMat(varargin)
% FROMREPMAT - returns array of equal GenEllipsoids the same
% size as stated in sizeVec argument
%
% ellArr=fromRepMat(sizeVec) - creates an array of size
% sizeVec of empty GenEllipsoids.
%
% ellArr=fromRepMat(dMat,sizeVec) - creates an array of size
% sizeVec of GenEllipsoids with diagonal matrix qMat.
%
% ellArr=fromRepMat(cVec,dMat,sizeVec) - creates an
% array of size sizeVec of GenEllipsoids with diagonal
% matrix qMat and center cVec.
%
% ellArr=fromRepMat(cVec,dMat,wMat,sizeVec) - creates an
% array of size sizeVec of GenEllipsoids with diagonal
% matrix dMat, square matrix wMat and center cVec.
%
% Input:
% Case1:
% regular:
% sizeVec: double[1,n] - vector of size, have
% integer values.
%
% Case2:
% regular:
% dMat: double[nDim, nDim] / dVec: double[nDim,1] -
% shape matrix of GenEllipsoids.
% sizeVec: double[1,n] - vector of size, have
% integer values.
%
% Case3:
% regular:
% cVec: double[nDim,1] - center vector of
% GenEllipsoids
% dMat: double[nDim, nDim] / dVec: double[nDim,1] -
% shape matrix of GenEllipsoids.
% sizeVec: double[1,n] - vector of size, have
% integer values.
%
% Case4:
% regular:
% cVec: double[nDim,1] - center vector of
% GenEllipsoids
% dMat: double[nDim, nDim] / dVec: double[nDim,1] -
% shape matrix of GenEllipsoids.
% wMat: double[nDim, nDim] - square matrix of GenEllipsoids.
% sizeVec: double[1,n] - vector of size, have
% integer values.
%
% Output:
% ellArr: ellipsoid[] - created GenEllipsoidal array
%
% $Author: Alexandr Timchenko <[email protected]> $
% $Date: Dec-2015$
% $Copyright: Moscow State University,
% Faculty of Computational Mathematics and Computer Science,
% System Analysis Department 2015 $
%
import modgen.common.checkvar;
import elltool.core.GenEllipsoid;
%
if nargin>4
indVec=[1:4,5:nargin];
sizeVec=varargin{4};
else
sizeVec=varargin{nargin};
indVec=[1:nargin-1];
end
%
if ~isa(sizeVec,'double')
modgen.common.throwerror('wrongInput','Size array is not double');
end
sizeVec=gras.la.trytreatasreal(sizeVec);
checkvar(sizeVec,@(x) all(mod(x(:),1) == 0)&&all(x(:) > 0) ...
&& (size(x,1)==1),'errorTag','wrongInput', ...
'errorMessage','size array must contain positive integer values.');
%
nEllipsoids=prod(sizeVec);
ellArr(nEllipsoids)=GenEllipsoid();
%
ell=GenEllipsoid(varargin{indVec});
arrayfun(@(x)makeEllipsoid(x),1:nEllipsoids);
ellArr=reshape(ellArr,sizeVec);
%
function makeEllipsoid(index)
ellArr(index)=getCopy(ell);
end
end

0 comments on commit 0334b60

Please sign in to comment.