Rev | Line | |
---|
[37] | 1 | function Y=sdpvarfun(varargin) |
---|
| 2 | %SDPVARFUN Applies operator on matrix variable |
---|
| 3 | % |
---|
| 4 | % Y = sdpvarfun('op',X) Applies the Matlab operator 'op' on X |
---|
| 5 | % |
---|
| 6 | % Example : Y = sdpvarfun('triu',X) Extracts upper triangluar part |
---|
| 7 | |
---|
| 8 | % Author Johan Löfberg |
---|
| 9 | % $Id: sdpvarfun.m,v 1.1 2006/08/10 18:00:22 joloef Exp $ |
---|
| 10 | |
---|
| 11 | op = varargin{1}; |
---|
| 12 | if ~isa(op,'char') |
---|
| 13 | error('First argument must be a string with the function name') |
---|
| 14 | end |
---|
| 15 | |
---|
| 16 | X = varargin{2}; |
---|
| 17 | Y = X; |
---|
| 18 | |
---|
| 19 | x_lmi_variables = X.lmi_variables; |
---|
| 20 | lmi_variables = []; |
---|
| 21 | |
---|
| 22 | Y.basis = []; |
---|
| 23 | opX = feval(op,reshape(X.basis(:,1),X.dim(1),X.dim(2))); |
---|
| 24 | Y.basis = opX(:); |
---|
| 25 | |
---|
| 26 | j = 1; |
---|
| 27 | for i = 1:length(x_lmi_variables) |
---|
| 28 | opX = feval(op,reshape(X.basis(:,i+1),X.dim(1),X.dim(2))); |
---|
| 29 | if (norm(opX,inf)>0) |
---|
| 30 | Y.basis(:,j+1) = opX(:); |
---|
| 31 | lmi_variables = [lmi_variables x_lmi_variables(i)]; |
---|
| 32 | j = j+1; |
---|
| 33 | end |
---|
| 34 | end |
---|
| 35 | Y.dim(1) = size(opX,1); |
---|
| 36 | Y.dim(2) = size(opX,2); |
---|
| 37 | Y.lmi_variables = lmi_variables; |
---|
| 38 | % Reset info about conic terms |
---|
| 39 | Y.conicinfo = [0 0]; |
---|
Note: See
TracBrowser
for help on using the repository browser.