source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/@sdpvar/assign.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 assign(X,value,ls)
2%ASSIGN Assigns a numerical value to an sdpvar
3%
4% ASSIGN(X,value)   Tries to set the free variables in X so that 
5%                   double(X)=value. Notice that other variables
6%                   sharing the same free variables will be affected.
7%                   If the assignment is infeasible, an error message
8%                   will be issued.
9%
10% ASSIGN(X,value,1) Least square assignment.
11
12% Author Johan Löfberg
13% $Id: assign.m,v 1.4 2006/08/09 13:47:43 joloef Exp $ 
14
15if nargin<3
16    ls = 0;
17end
18
19if ~isa(X,'sdpvar')
20    error('First argument should be an SDPVAR object.');
21end
22
23if ~isa(value,'double')
24    error('Second argument should be a DOUBLE.');
25end
26
27if prod(size(value)) == 1
28    value = repmat(value,size(X));
29end
30
31if ~isequal(size(X),size(value))
32  error('Both arguments must have same size')
33end
34if ~isa(X,'sdpvar')
35  error('First arguments must be an sdpvar object')
36end
37
38if is(X,'complex')
39    assign(real(X),real(value));
40    assign(imag(X),imag(value));
41    return
42end
43
44x_lmi_variables = X.lmi_variables;
45b = value(:)-X.basis(:,1);
46A = X.basis(:,2:end);
47feas_var = A\b;
48% Improve
49e = A*feas_var-b;
50de = A\e;
51feas_var = feas_var-de;
52
53if ~ls
54    if norm(A*feas_var-b)>sqrt(eps)
55        error('Inconsistent assignment')
56    end
57end
58
59sol = yalmip('getsolution');
60keep_these = find(~ismember(sol.variables,x_lmi_variables));
61sol.optvar = [sol.optvar(keep_these);feas_var(:)];
62sol.variables = [sol.variables(keep_these);x_lmi_variables(:)];
63yalmip('setallsolution',sol);
64
65
66
Note: See TracBrowser for help on using the repository browser.