summaryrefslogtreecommitdiff
path: root/math/sedumi/files/patch-and_or
blob: 2d3675f769cfec7eac09c36846d977d94079e480 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
--- checkpars.m	2008-10-06 10:28:27.000000000 +0900
+++ checkpars.m	2008-10-06 10:28:59.000000000 +0900
@@ -41,7 +41,7 @@
 % --------------------------------------------------
 % Algorithm selection parameters
 % --------------------------------------------------
-if ~isfield(pars,'alg') | sum([0 1 2] == pars.alg) == 0
+if ~isfield(pars,'alg') || sum([0 1 2] == pars.alg) == 0
     pars.alg = 2;
 end
 if ~isfield(pars,'beta')       % 0.1 <= beta <= 0.9 (theoretically in (0,1))
@@ -88,7 +88,7 @@
 % --------------------------------------------------
 % Initialization
 % --------------------------------------------------
-if ~isfield(pars,'mu') | pars.mu <= 0
+if ~isfield(pars,'mu') || pars.mu <= 0
     pars.mu = 1;
 end
 % --------------------------------------------------

--- getsymbada.m	2008-10-06 10:28:27.000000000 +0900
+++ getsymbada.m	2008-10-06 10:34:06.000000000 +0900
@@ -42,7 +42,7 @@
 
 Alpq = spones(extractA(At,Ablkjc,0,3,1,psdblkstart(1)));
 Ablks = findblks(At,Ablkjc,3,[],psdblkstart);
-if spars(Ablks)==1 | spars(Alpq)==1 | (~isempty(DAt.q) & spars(DAt.q)==1)
+if spars(Ablks)==1 || spars(Alpq)==1 || (~isempty(DAt.q) && spars(DAt.q)==1)
     SYMBADA=sparse(ones(size(At,2),size(At,2)));
 else
     SYMBADA = Alpq' * Alpq + Ablks'*Ablks + DAt.q'*DAt.q;

--- optstep.m	2008-10-06 10:28:27.000000000 +0900
+++ optstep.m	2008-10-06 10:30:28.000000000 +0900
@@ -48,7 +48,7 @@
     z0 = x0 / d.l(1);
     %This value is never used.
     %deptol = 1E-10 * max(x0,z0);
-    if (feasratio < -0.5) & (x0 < z0*z0)
+    if (feasratio < -0.5) && (x0 < z0*z0)
         x0 = 0;                          % Try project onto direction.
     end
     % ------------------------------------------------------------
@@ -82,7 +82,7 @@
     % ----------------------------------------
     % CHECK WHETHER x[B] >= 0 AND WHETHER RESIDUAL DID NOT DETERIORATE.
     % ----------------------------------------
-    if (min(x) < 0.0) | ...
+    if (min(x) < 0.0) || ...
             (norm(err.b,inf) > 5 * max(max(y0,1e-10 * x0) * R.maxb, y0 * R.maxRb))
         x = [];  % Incorrect guess of LP-basis
         return
@@ -111,7 +111,7 @@
         cx = c'*x;
         by = b'*y;
         z0 = by - cx; %[JFS 9/2003: changed condition below
-        if (~isempty(lpNB) & (min(z(lpNB)) < 0.0)) | ...
+        if (~isempty(lpNB) && (min(z(lpNB)) < 0.0)) || ...
                 normzB > 5 * max(1E-10 * (x0+(x0==0)) * norm(c), min(y0,1e-8) * norm(R.c))
             x = [];  % Incorrect guess of LP-basis
             return

--- posttransfo.m	2008-10-06 10:28:27.000000000 +0900
+++ posttransfo.m	2008-10-06 10:34:23.000000000 +0900
@@ -82,7 +82,7 @@
 % ----------------------------------------
 % Postprocess the SDP part
 % ----------------------------------------
-if pars.sdp==1 & isfield(prep,'sdp')
+if pars.sdp==1 && isfield(prep,'sdp')
     xpf(1:K.f,1)=xp(1:K.f);
     xp=xp(K.f+1:end);
     Kf=K.f;

--- pretransfo.m	2008-10-06 10:28:27.000000000 +0900
+++ pretransfo.m	2008-10-06 10:37:11.000000000 +0900
@@ -43,14 +43,14 @@
     K.f = 0;
 elseif isempty(K.f)
     K.f = 0;
-elseif (K.f~= floor(K.f)) | (K.f < 0)
+elseif (K.f~= floor(K.f)) || (K.f < 0)
     error('K.f should be nonnegative integer')
 end
 if ~isfield(K,'l')                        % K.l
     K.l = 0;
 elseif isempty(K.l)
     K.l = 0;
-elseif (K.l~= floor(K.l)) | (K.l < 0)
+elseif (K.l~= floor(K.l)) || (K.l < 0)
     error('K.l should be nonnegative integer')
 end
 if ~isfield(K,'q')                       % K.q
@@ -58,7 +58,7 @@
 elseif sum(K.q) == 0
     K.q = [];
 elseif ~isempty(K.q)
-    if (min(K.q) < 2) | any(K.q~= floor(K.q))
+    if (min(K.q) < 2) || any(K.q~= floor(K.q))
         error('K.q should contain only integers bigger than 1')
     end
     if size(K.q,1) > 1
@@ -70,7 +70,7 @@
 elseif sum(K.r) == 0
     K.r = [];
 elseif ~isempty(K.r)
-    if (min(K.r) < 3) | any(K.r~= floor(K.r))
+    if (min(K.r) < 3) || any(K.r~= floor(K.r))
         error('K.r should contain only integers bigger than 2')
     end
     if size(K.r,1) > 1
@@ -82,7 +82,7 @@
 elseif sum(K.s) == 0
     K.s = [];
 elseif ~isempty(K.s)
-    if min(K.s < 1) | any(K.s~= floor(K.s))
+    if min(K.s < 1) || any(K.s~= floor(K.s))
         error('K.s should contain only positive integers')
     end
     if size(K.s,1) > 1
@@ -95,7 +95,7 @@
 if ~isfield(K,'ycomplex')                        % K.ycomplex
     K.ycomplex = [];
 elseif ~isempty(K.ycomplex)
-    if  (min(K.ycomplex) < 1) | (min(size(K.ycomplex)) > 1) | ...
+    if  (min(K.ycomplex) < 1) || (min(size(K.ycomplex)) > 1) || ...
             any(K.ycomplex~= floor(K.ycomplex))
         error('K.ycomplex should be a list containing only positive integers')
     end
@@ -109,7 +109,7 @@
 if ~isfield(K,'xcomplex')                        % K.xcomplex
     K.xcomplex = [];
 elseif ~isempty(K.xcomplex)
-    if  (min(K.xcomplex) < 1) | (min(size(K.xcomplex))) > 1 | ...
+    if  (min(K.xcomplex) < 1) || (min(size(K.xcomplex))) > 1 || ...
             any(K.xcomplex~= floor(K.xcomplex))
         error('K.xcomplex should be a list containing only positive integers')
     end
@@ -123,7 +123,7 @@
 if ~isfield(K,'scomplex')                        % K.scomplex
     K.scomplex = [];
 elseif ~isempty(K.scomplex)
-    if  min(K.scomplex) < 1 |  min(size(K.scomplex)) > 1 | ...
+    if  min(K.scomplex) < 1 ||  min(size(K.scomplex)) > 1 || ...
             any(K.scomplex~= floor(K.scomplex))
         error('K.scomplex should be a list containing only positive integers')
     end
@@ -138,7 +138,7 @@
 % Check size of At,b,c (w.r.t. K)
 % Let m = #eq-constraints, N = #variables (before transformations)
 % ----------------------------------------
-if (min(size(b)) > 1) | (min(size(c)) > 1)
+if (min(size(b)) > 1) || (min(size(c)) > 1)
     error('Parameters b and c must be vectors')
 end
 m = min(size(At));
@@ -175,16 +175,16 @@
 % ------------------------------------------------------------
 % Check for NaN and Inf
 % ------------------------------------------------------------
-if any(any(isnan(At))) | any(isnan(b)) | any(isnan(c))
+if any(any(isnan(At))) || any(isnan(b)) || any(isnan(c))
     error('A,b,c data contains NaN values')
 end
-if any(any(isinf(At))) | any(isinf(b)) | any(isinf(c))
+if any(any(isinf(At))) || any(isinf(b)) || any(isinf(c))
     error('A,b,c data contains Inf values')
 end
 % ------------------------------------------------------------
 % Save the standardized data for further use if needed
 % ------------------------------------------------------------
-if isfield(pars,'errors') & pars.errors==1
+if isfield(pars,'errors') && pars.errors==1
     origcoeff.At=At;
     origcoeff.c=c;
     origcoeff.b=b;
@@ -271,7 +271,7 @@
 if ~isfield(pars,'free')
     pars.free=1;
 end
-if pars.free & K.l>0
+if pars.free && K.l>0
     stest=c(K.f+1:K.f+K.l)-At(K.f+1:K.f+K.l,:)*rand(m,1);
     %Now we detect if stest contains the same vector twice, or opposite
     %vectors.

--- sedumi.m	2008-10-06 10:28:27.000000000 +0900
+++ sedumi.m	2008-10-06 10:35:24.000000000 +0900
@@ -293,10 +293,10 @@
             my_fprintf(pars.fid,'Detected %i diagonal SDP block(s) with %i linear variables\n',blockcount,varcount);
         end
     end
-    if isfield(prep,'freeblock1') & length(prep.freeblock1)>0
+    if isfield(prep,'freeblock1') && length(prep.freeblock1)>0
         my_fprintf(pars.fid,'Detected %i free variables in the linear part\n',length(prep.freeblock1));
     end
-    if isfield(prep,'Kf') & prep.Kf>0
+    if isfield(prep,'Kf') && prep.Kf>0
         switch pars.free
             case 0
                 my_fprintf(pars.fid,'Split %i free variables\n',prep.Kf);
@@ -384,9 +384,9 @@
         keyboard
     end
     
-    if pars.stepdif==2 & ...
-            (iter>20 | (iter>1 & (err.kcg + Lsd.kcg>3)) | ...
-            (iter>5 & abs(1-feasratio)<0.05) )
+    if pars.stepdif==2 && ...
+            (iter>20 || (iter>1 && (err.kcg + Lsd.kcg>3)) || ...
+            (iter>5 && abs(1-feasratio)<0.05) )
         pars.stepdif=1;
     end
     % --------------------------------------------------
@@ -438,7 +438,7 @@
     meritOld = merit;
     merit = (sum(R.w) + max(R.sd,0))^2 * y0 / R.b0;
     rate = merit / meritOld;
-    if (rate >= 0.9999) & (wr.desc == 1)
+    if (rate >= 0.9999) && (wr.desc == 1)
         % ------------------------------------------------------------
         % STOP = -1  --> Stop due to numerical problems
         % ------------------------------------------------------------
@@ -470,7 +470,7 @@
     % If we get in superlinear region of LP,
     % try to guess optimal solution:
     % ----------------------------------------
-    if lponly & (rate < 0.05)
+    if lponly && (rate < 0.05)
         [xsol,ysol] = optstep(A,b,c, y0,y,d,v,dxmdz, ...
             K,L,symLden,dense, Ablkjc,Aord,ADA,DAt, feasratio, R,pars);
         if ~isempty(xsol)
@@ -478,7 +478,7 @@
             feasratio = 1 - 2*(xsol(1)==0);
             break
         end
-    elseif (by > 0) & (abs(1+feasratio) < 0.05) & (R.b0*y0 < 0.5)
+    elseif (by > 0) && (abs(1+feasratio) < 0.05) && (R.b0*y0 < 0.5)
         if max(eigK(full(qreshape(Amul(A,dense,y,1),1,K)),K)) <= pars.eps * by
             STOP = 3;                   % Means Farkas solution found !
             break
@@ -576,7 +576,7 @@
         % If the quality of the Farkas solution is good and better than
         % the approx. feasible soln, set x0=0: Farkas solution found.
         % ------------------------------------------------------------
-        if (reldirinf < pars.eps) | (relinf > max(pars.bigeps, reldirinf))
+        if (reldirinf < pars.eps) || (relinf > max(pars.bigeps, reldirinf))
             x0 = 0.0;
             pinf = pdirinf;
             dinf = ddirinf;
@@ -654,7 +654,7 @@
         my_fprintf(pars.fid, 'Failed: no sensible solution/direction found.\n');
         info.numerr = 2;
     elseif STOP == -1
-        if (pinf > -pars.eps * cx) & (dinf > pars.eps * by)
+        if (pinf > -pars.eps * cx) && (dinf > pars.eps * by)
             info.numerr = 1;
         else
             info.numerr = 0;

--- stepdif.m	2008-10-06 10:28:27.000000000 +0900
+++ stepdif.m	2008-10-06 10:35:37.000000000 +0900
@@ -61,7 +61,7 @@
 % CASE Rsd > 0: gap constraint locally part of merit.
 % CASE Rsd < 0: gap constraint locally not part of merit.
 % ------------------------------------------------------------
-usegap = (R.sd > 0) | (R.sd == 0 & dRg > 0);
+usegap = (R.sd > 0) || (R.sd == 0 && dRg > 0);
 if usegap
     r0 = R.w(1)+R.w(2)+R.sd;
     beta = (rdy0 * R.w(1) + rcdx)/ r0;
diff -u widelen.m widelen.m
--- widelen.m	2008-10-06 10:28:27.000000000 +0900
+++ widelen.m	2008-10-06 10:32:16.000000000 +0900
@@ -71,7 +71,7 @@
 % ------------------------------------------------------------
 t = 0.0;
 ntry = 0;  % do loop at least once
-while (t < 0.5 * tR) | ( (fullt-tR) + (1e-7 * fullt) < (tR - t) ) | ntry==0
+while (t < 0.5 * tR) || ( (fullt-tR) + (1e-7 * fullt) < (tR - t) ) || ntry==0
     ntry = 1;
     if tR == maxt                       % Bisection
         tM = 0.1 * t + 0.9 * tR;
@@ -105,7 +105,7 @@
     % ALL:
     wM.lab = [xM(1:K.l).*zM(1:K.l); detxz ./ lab2q; lab2q; psdeig(wM.s,K)];
     [deltaM,hM,alphaM] = iswnbr(wM.lab, thetaSQR);
-    if (deltaM <= pars.beta) | ((tM < fullt / 10) & (deltaM < 1))
+    if (deltaM <= pars.beta) || ((tM < fullt / 10) && (deltaM < 1))
         w = wM;
         t = tM;
         wr.h=hM;

--- wregion.m	2008-10-06 10:45:27.000000000 +0900
+++ wregion.m	2008-10-06 10:45:48.000000000 +0900
@@ -62,9 +62,9 @@
     [uzc.u,zispos] = psdfactor(zc,K);
     critval = max(y0, sqrt(min(d.l(1),1/d.l(1)))*v(1));    % >= y0
     critval = max(1E-3, pars.cg.restol) * critval * R.maxRb;
-    if (~xispos) | (~zispos) | (errc.maxb > critval) ...
-            | ( (~isempty(uxc.tdet)) & (min(uxc.tdet) <= 0.0)) ...
-            | ( (~isempty(uzc.tdet)) & (min(uzc.tdet) <= 0.0))
+    if (~xispos) || (~zispos) || (errc.maxb > critval) ...
+            || ( (~isempty(uxc.tdet)) && (min(uxc.tdet) <= 0.0)) ...
+            || ( (~isempty(uzc.tdet)) && (min(uzc.tdet) <= 0.0))
         STOP = -1;   % Reject and terminate
         dxmdz = [];
         err = errc;
@@ -121,7 +121,7 @@
     % i.e. errb <= phi*(-dy0) * (1+t*dy0/y0) * maxRb
     % ----------------------------------------
     PHI = 0.5;
-    if dy0 < 0 & (PHI*dy0^2*R.maxRb)~=0
+    if dy0 < 0 && (PHI*dy0^2*R.maxRb)~=0
         critval =  - (PHI * dy0*R.maxRb + err.maxb)*y0c / (PHI*dy0^2*R.maxRb);
     else
         critval = 1;