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

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

Added original make3d

File size: 1.5 KB
Line 
1function F = sdpvar(X)
2% SDPVAR Converts a block variable to standard SDPVAR
3
4% Author Johan Löfberg
5% $Id: sdpvar.m,v 1.4 2005/06/17 13:02:01 joloef Exp $
6
7
8% first, check that we have filled everything.
9[n,m] = size(X.blocks);
10
11if n==m
12    % Perform symmetric extension
13    for i = 1:n
14        for j = i+1:n
15            if isempty(X.blocks{i,j})
16                X.blocks{i,j} = X.blocks{j,i};
17            elseif isempty(X.blocks{j,i})
18                X.blocks{j,i} = X.blocks{i,j}';
19            end
20        end
21    end
22end
23
24for i = 1:n
25    for j = 1:m
26        ns(i,j) = size(X.blocks{i,j},1);
27        ms(i,j) = size(X.blocks{i,j},2);
28        % Indicate zero/eye blocks (simplies code below)
29        if ns(i,j)==1 & ms(i,j) == 1 & isequal(X.blocks{i,j},0)
30            ns(i,j) = 0;
31            ms(i,j) = 0;
32        end
33    end
34end
35
36newns = ns;
37newms = ms;
38
39% Expand missing elements
40for i = 1:n
41    for j = 1:m
42        if ns(i,j) == 0
43            ns(i,j) = max(ns(i,:));
44        end
45        if ms(i,j) == 0
46            ms(i,j) = max(ms(:,j));
47        end
48    end
49end
50
51if any(any(ns==0)) | any(any(ms==0))
52    error('I cannot determine the implied size of some of the blocks');
53end
54
55F = [];
56for i = 1:n
57    Y = [];
58    for j = 1:m
59        if isequal(X.blocks{i,j},0)
60            Y = [Y zeros(ns(i,j),ms(i,j))];
61        elseif isequal(X.blocks{i,j},1)
62            Y = [Y eye(ns(i,j))];
63        elseif isempty(X.blocks{i,j}) & isempty(X.blocks{j,i})
64            Y = [Y zeros(ns(i,j),ms(i,j))];
65        else
66            Y = [Y X.blocks{i,j}];
67        end
68    end
69    F = [F;Y];
70end
Note: See TracBrowser for help on using the repository browser.