-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #42 Enhancement: function fromRepMat added
- Loading branch information
Showing
1 changed file
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |