source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/@ncvar/ctranspose.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.7 KB
Line 
1function X=ctranspose(X)
2%CTRANSPOSE (overloaded)
3
4% Author Johan Löfberg
5% $Id: ctranspose.m,v 1.2 2006/08/28 13:48:38 joloef Exp $
6
7if isa(X,'blkvar')
8    X = sdpvar(X);
9end
10
11n = X.dim(1);
12m = X.dim(2);
13ind = reshape(reshape(1:n*m,n,m)',n*m,1);
14if isreal(X.basis)
15    X.basis = X.basis(ind,:);   
16else
17   X.basis = conj(X.basis(ind,:));
18end
19X.dim(1) = m;
20X.dim(2) = n;
21% Reset info about conic terms
22X.conicinfo = [0 0];
23
24% Flip noncommuting terms
25% Get all the tables, and expand them so that they correspond to the same
26% number of variables globally (nonCommutingTable is not up to date after a
27% new commuting variables has been defined, to save flops)
28nonCommutingTable         = yalmip('nonCommutingTable');
29[monomtable,variabletype] = yalmip('monomtable');
30if size(monomtable,1)>size(nonCommutingTable,1)
31    nonCommutingTable((1+size(nonCommutingTable,1)):(size(monomtable,1)),1) = (1+size(nonCommutingTable,1)):(size(monomtable,1));
32end
33% Cast commutative variables as nc temporarily by adding them to the table
34commuting = find(~any(nonCommutingTable,2));
35nonCommutingTable(commuting,1) = commuting;
36
37for i = 1:length(X.lmi_variables)
38    if nonCommutingTable(X.lmi_variables(i),2)
39        monoms = nonCommutingTable(X.lmi_variables(i),2:end);     
40        monoms(find(monoms)) = fliplr( monoms(find(monoms)));
41        monoms = [nonCommutingTable(X.lmi_variables(i),1) monoms];
42        old = findrows(nonCommutingTable,monoms);
43        old = findrows(nonCommutingTable(:,2:end),monoms(2:end));
44        if ~isempty(old)
45            old = old(find((monoms(1) == nonCommutingTable(old,1)) | isnan(monoms(1)) & isnan(nonCommutingTable(old,1))));
46        end
47        if isempty(old)
48            % Create a new monomial
49            monomtable(end+1,end+1) = 0;
50            variabletype(end+1) = variabletype(X.lmi_variables(i));
51            nonCommutingTable = [nonCommutingTable;monoms];
52            X.lmi_variables(i) = size(nonCommutingTable,1);
53        else
54            X.lmi_variables(i) = old;
55        end
56    end
57end
58% Fucked up order (lmi_variables should be sorted and unique)
59if any(diff(X.lmi_variables)<0)
60    [i,j]=sort(X.lmi_variables);
61    X.basis = [X.basis(:,1) X.basis(:,j+1)];
62    X.lmi_variables = X.lmi_variables(j);
63end
64[un_Z_vars2] = uniquestripped(X.lmi_variables);
65if length(un_Z_vars2) < length(X.lmi_variables)
66    [un_Z_vars,hh,jj] = unique(X.lmi_variables);
67    if length(X.lmi_variables) ~=length(un_X_vars)
68        X.basis = Z.basis*sparse([1 1+jj],[1 1+(1:length(jj))],ones(1,1+length(jj)))';
69        X.lmi_variables = un_Z_vars;
70    end
71end
72if size(monomtable,2) < size(monomtable,1)
73    monomtable(size(monomtable,1),size(monomtable,1)) = 0;
74end
75yalmip('nonCommutingTable',nonCommutingTable);
76yalmip('setmonomtable',monomtable,variabletype);
Note: See TracBrowser for help on using the repository browser.