diff --git a/products/+elltool/+core/@GenEllipsoid/fromRepMat.m b/products/+elltool/+core/@GenEllipsoid/fromRepMat.m new file mode 100644 index 00000000..184a0cab --- /dev/null +++ b/products/+elltool/+core/@GenEllipsoid/fromRepMat.m @@ -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 $ +% $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 \ No newline at end of file