-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_spy.m
39 lines (37 loc) · 978 Bytes
/
plot_spy.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
% To plot spy figures of L overlapped on M
% L is plotted as red circles, M is plotted as blue circles
function chk = plot_spy(M, L)
M_reg = M + size(M,1)*eye(size(M,1));
figure(101)
subplot(121)
hold on
for i = 1:size(M,1)
for j = 1:i
if(M(i,j)~=0)
plot(j, size(M,1) - i, 'ob', 'MarkerFaceColor', 'b');
plot(i, size(M,1) - j, 'ob', 'MarkerFaceColor', 'b');
end
end
end
xticks([0:10:40])
set(gca,'YTickLabel',flipud(get(gca,'YTickLabel')));
xlabel(['nz = ', num2str(nnz(M_reg))]);
title('KKT sparsity');
subplot(122)
hold on
for i = 1:size(M,1)
for j = 1:i
if(L(i,j)~=0)
plot(j, size(M,1) - i, 'or', 'MarkerFaceColor', 'r');
end
if(M_reg(i,j)~=0)
plot(j, size(M,1) - i, 'ob', 'MarkerFaceColor', 'b');
end
end
end
xticks([0:10:40])
set(gca,'YTickLabel',flipud(get(gca,'YTickLabel')));
xlabel(['nz = ', num2str(nnz(L))]);
title('L sparsity');
chk = 1;
end