-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlotMatrices.m
169 lines (119 loc) · 4.05 KB
/
PlotMatrices.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
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
% Plot combinatorial matrices
%
% [email protected], 2019
clear; close all;
addpath src
N = 7;
LAMBDA = amat(N);
LAMBDAINV = inv(LAMBDA);
f1 = figure;
imagesc(LAMBDA); axis square; colormap(hot)
filename = sprintf('../figs/A7x7.pdf');
print(f1, filename, '-dpdf');
system(sprintf('pdfcrop --margins 10 %s %s', filename, filename));
f2 = figure;
imagesc(LAMBDAINV); axis square; colormap(hot)
filename = sprintf('../figs/Ainv7x7.pdf');
print(f2, filename, '-dpdf');
system(sprintf('pdfcrop --margins 10 %s %s', filename, filename));
%%
N = 7;
ZETA = zetamat(N);
ZETAINV = inv(ZETA);
f3 = figure;
imagesc(ZETA); axis square; colormap(hot)
filename = sprintf('../figs/ZETA%dx%d.pdf', N, N);
print(f3, filename, '-dpdf');
system(sprintf('pdfcrop --margins 10 %s %s', filename, filename));
f4 = figure;
imagesc(ZETAINV); axis square; colormap(hot)
filename = sprintf('../figs/ZETAinv%dx%d.pdf', N, N);
print(f4, filename, '-dpdf');
system(sprintf('pdfcrop --margins 10 %s %s', filename, filename));
%% "Fish skeleton matrix"
f5 = figure;
LL = LAMBDA*LAMBDA';
imagesc(LL); axis square;
filename = sprintf('../figs/lambdalambdaT.pdf');
print(f5, filename, '-dpdf');
system(sprintf('pdfcrop --margins 10 %s %s', filename, filename));
f6 = figure;
ZZ = ZETA*ZETA';
imagesc(ZZ); axis square; colormap(hot);
filename = sprintf('../figs/zetazetaT.pdf');
print(f6, filename, '-dpdf');
system(sprintf('pdfcrop --margins 10 %s %s', filename, filename));
%%
f7 = figure;
imagesc(LAMBDAINV*LAMBDAINV'); axis square; colormap(hot)
pdfcrop(0.69, 0.91);
filename = sprintf('../figs/lambdainvlambdainvT.pdf');
print(f7, filename, '-dpdf');
system(sprintf('pdfcrop --margins 10 %s %s', filename, filename));
f8 = figure;
imagesc(ZETAINV'*ZETAINV); axis square; colormap(hot)
pdfcrop(0.69, 0.91);
filename = sprintf('../figs/zetainvTzetainv.pdf');
print(f8, filename, '-dpdf');
system(sprintf('pdfcrop --margins 10 %s %s', filename, filename));
%%
f9 = figure;
zeta = zetamat(N);
%zeta = zeta(2:end, 2:end);
subplot(2,4,1); imagesc(zeta); colormap hot; axis square; title('$\zeta$','interpreter','latex');
subplot(2,4,2); imagesc(inv(zeta)); axis square; title('$\zeta^{-1}$','interpreter','latex');
A = amatfull(N);
A_inv = inv(A);
subplot(2,4,3); imagesc(A); axis square; title('$A$','interpreter','latex');
subplot(2,4,4); imagesc(A_inv); axis square; title('$A^{-1}$','interpreter','latex');
M = (A*inv(zeta))';
M_inv = ~fliplr(inv(double(M)));
subplot(2,4,5); imagesc(M); axis square; title('$M = (\zeta A^{-1})^T$','interpreter','latex');
subplot(2,4,6); imagesc(M_inv); axis square; title('$M^{-1}$','interpreter','latex');
%colormap gray;
% M*zeta = A
% M = A*inv(zeta)
% zeta = M*A
% M = zeta * inv(A)
%% Adjacency matrix
close all;
N = 6;
A = hypercube(N);
f10 = figure;
imagesc(0:2^N-1, 0:2^N-1, A); colormap(hot);
xticks([0:8:2^N]);
yticks([0:8:2^N]);
axis square;
filename = sprintf('../figs/adjmatrixN%d.pdf', N);
print(f10, filename, '-dpdf');
system(sprintf('pdfcrop --margins 10 %s %s', filename, filename));
% Degree matrix (each vertex is connected by N edges)
D = eye(2^N)*N; % Same as diag(sum(A))
% Laplacian matrix L = D - A
L = D - A;
% Symmetric Laplacian matrix
Lsym = eye(2^N) - D^(-1/2) * A * D^(-1/2);
imagesc(Lsym);
%%
% Resistance distance
% http://mathworld.wolfram.com/ResistanceDistance.html
Gamma = L + 1/(2^N);
Omega = zeros(2^N);
invGamma = inv(Gamma);
for i = 1:2^N
for j = 1:2^N
Omega(i,j) = invGamma(i,i) + invGamma(i,j) - 2*invGamma(i,j);
end
end
figure;
imagesc(Omega);
axis square;
% Graph connections
GR = graph(A);
fg = figure;
plot(GR,'layout','circle','NodeLabel',0:2^N-1);
axis square;
axis off;
filename = sprintf('../figs/graphN%d.pdf', N);
print(fg, filename, '-dpdf');
system(sprintf('pdfcrop --margins 10 %s %s', filename, filename));