-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcheckSubproblemConverged.m
44 lines (44 loc) · 1.85 KB
/
checkSubproblemConverged.m
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
function converged = checkSubproblemConverged(K, Q, M, I, A, C, L, S, X, closures, mmse, reserve)
converged = true;
for l = 1 : K
for q = 1 : Q
for k = closures(l, :)
if k == 0
continue;
end
for i = 1 : I
rowOffset = (l - 1) * Q * M + (q - 1) * M;
colOffset = (k - 1) * I + i;
c = C(rowOffset + 1 : rowOffset + M, colOffset);
lambda = L((k - 1) * I + i);
rowOffset = (l - 1) * Q * M + (q - 1) * M;
colOffset = (k - 1) * I + i;
x = X(rowOffset + 1 : rowOffset + M, colOffset);
a = A((l - 1) * Q + q, (k - 1) * I + i);
if norm(c, 2) <= lambda / 2 || a <= 1.001 * reserve
if norm(x, 2) ~= 0
converged = false;
return
end
elseif norm(x) > 0
multiplier = S((l - 1) * Q + q, (k - 1) * I + i);
offset = (l - 1) * Q * M + (q - 1) * M;
mm = mmse(offset + 1 : offset + M, offset + 1 : offset + M);
if abs(multiplier * (a - norm(x, 2)^2)) > 1e-3
converged = false;
return
end
rep = -2 * norm(x, 2) / lambda * (multiplier * x + mm * x - c);
if norm(rep - x, 2)^2 > (0.01 * norm(x, 2)^2)
converged = false;
return
end
else
converged = false;
return
end
end
end
end
end
return