Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Companion to "Pfaffian Point Processes for Two Classes of Random Plane Partitions"

27669 views
1
from itertools import combinations
2
from itertools import product
3
load('mat_to_list.sage')
4
5
6
############################################################
7
#### Conversion Tools
8
############################################################
9
10
11
def array_to_tsscpp(A):
12
"""
13
array_to_tsscpp(A)
14
15
Takes a TSSCPP array (see Section 6.2 of "Proofs and
16
Confirmations" by David M. Bressoud), and returns the
17
encoded TSSCPP in the form of a 2n-by-2n "bird's-eye
18
view" matrix
19
20
Inputs
21
A: An n-by-n integer matrix encoding a TSSCPP array
22
23
Output
24
M: a 2n-by-2n bird's-eye view matrix of the TSSCPP
25
encoded in A
26
"""
27
n = A.ncols()
28
M = matrix(ZZ, 2*n, 2*n)
29
30
# set the top-left quadrant
31
M[0:n, 0:n] = n
32
for i in [0..n-1]:
33
# fill in blocks belonging to ith shell
34
for j in [0..n-1]:
35
a = A[i,j]
36
k = (a-1)/2
37
if a != 0:
38
M[j,j] = M[j,j] + 1
39
for l in [1..k]:
40
M[j+l,j] = M[j+l,j] + 1
41
M[j,j+l] = M[j,j+l] + 1
42
# fill in blocks belonging to previous shells
43
for l in [0..n-1]:
44
for m in [0..n-1]:
45
if l <= i-1 or m <= i-1:
46
M[l,m] = M[l,m] + 1
47
48
# set diagonal
49
for l in [0..2*n-1]:
50
M[l,2*n-1-l] = n
51
52
# set bottom-right quadrant
53
for l in [0..n-1]:
54
for m in [0..n-1]:
55
M[n+l,n+m] = 2*n - M[n-1-l,n-1-m]
56
57
# set remaining off-diagonal entries
58
for l in [0..n-2]:
59
for m in [0..n-l-2]:
60
c = 0
61
for r in [0..n-1]:
62
if M[2*n-r-1, n+m] <= l:
63
c = c + 1
64
else:
65
break
66
M[l, n+m] = 2*n - c
67
M[n+m, l] = 2*n - c
68
M[n-m-1, 2*n-l-1] = c
69
M[2*n-l-1, n-m-1] = c
70
return(M)
71
72
def tsscpp_to_array(M):
73
"""
74
tsscpp_to_array(M)
75
76
Takes a TSSCPP in the form of a bird's-eye view matrix
77
M and returns the TSSCPP array that encodes M. Is the
78
inverse of function array_to_tsscpp(A)
79
80
Arguments
81
M: A 2n-by-2n bird's-eye view matrix of the TSSCPP
82
83
Outputs
84
A: An n-by-n TSSCPP array encoding M
85
"""
86
87
n = M.nrows()/2
88
A = Matrix(ZZ, n, n)
89
90
for i in [0..n-1]:
91
partial_shell = Matrix(ZZ, n-i, n-i)
92
for l in [0..n-i-1]:
93
for m in [0..n-i-1]:
94
if M[l+i,m+i] >= 2*n - i:
95
partial_shell[l,m] = 1
96
97
for l in [0..n-i-1]:
98
if partial_shell[l,l] == 1:
99
counter = 1
100
for m in [l+1..n-i-1]:
101
if partial_shell[l,m] == 1:
102
counter = counter + 1
103
else:
104
break
105
A[i,i+l] = 2*counter - 1
106
return(A)
107
108
def plot_tsscpp(M, color_1='ghostwhite', color_2='lightsteelblue', color_3='slategrey'):
109
"""
110
plot_tsscpp(M)
111
112
Takes a TSSCPP in the form of a bird's-eye-view matrix M
113
and prints a plot of the TSSCPP
114
115
Inputs:
116
M: A 2n-by-2n bird's-eye view matrix of the TSSCPP
117
color_1: Color of lozenge 1
118
color_2: Color of lozenge 2
119
color_3: Color of lozenge 3
120
121
Output:
122
(None; prints graphics object)
123
"""
124
125
PPlist = mat_to_list(M)
126
PP = PlanePartition(PPlist)
127
return(PP.plot(show_box=True, colors=[color_1, color_2, color_3]))
128
129
def array_to_nilp(A, line_color='blue'):
130
"""
131
array_to_nilp(A)
132
133
Takes a TSSCPP array and returns a plot (as a graphics
134
object) of the nest of NILP's associated to the TSSCPP
135
136
Inputs:
137
A: An n-by-n integer matrix encoding a TSSCPP array
138
line_color: Name of the color of the paths
139
140
Output:
141
plot_frame: plot of the nest of NILP's
142
"""
143
144
n = A.nrows()
145
if 2*n-2 <= 12:
146
step = 2
147
else:
148
step = 5
149
150
verts = [[0,0], [n-1,2*n-2], [2*n-2,2*n-2]]
151
marks = [1 .. 2*n-2]
152
labels = ['${0}$'.format(i) if i % step == 0 else '' for i in [1 .. 2*n-2]]
153
154
plot_frame = polygon(verts, color='black', fill=False, gridlines='major',
155
ticks=[marks, marks], tick_formatter=[labels, labels])
156
line_weight = 2
157
158
for ii in [1 .. n-1]:
159
num_entries = 0
160
for kk in [ii .. n-1]:
161
if A[ii-1, kk] != 0:
162
num_entries += 1
163
else:
164
break
165
166
x_start = n-ii
167
y_start = 2*(n-ii)
168
line_points = [(x_start, y_start)]
169
170
if num_entries == 0:
171
line_points.append((y_start, y_start))
172
else:
173
for kk in [1 .. num_entries]:
174
entry = A[ii-1, ii-1+kk]
175
dist = (entry + 1)/2
176
x_upper = 2*x_start - (kk-1) - dist
177
y_upper = 2*x_start - (kk-1)
178
line_points.append((x_upper, y_upper))
179
line_points.append((x_upper, y_upper-1))
180
if kk == num_entries and x_upper != y_upper-1:
181
line_points.append((y_upper-1, y_upper-1))
182
183
plot_line = line(line_points, color=line_color, thickness=line_weight, alpha=1.0)
184
plot_frame += plot_line
185
return(plot_frame)
186
187
188
############################################################
189
#### Creation Tools
190
############################################################
191
192
193
def powerset_ordered(S):
194
"""
195
Produces the power set (the collection of all subsets)
196
of a set S
197
198
Inputs:
199
S: A finite set, as a list of integers
200
201
Output:
202
powerset: The power set of S, as a list whose elements
203
are the subsets of S, also as lists
204
"""
205
powerset = []
206
207
size = len(S)
208
for n_elems in [0..size]:
209
if n_elems == 0:
210
powerset.append([])
211
else:
212
combs = list(combinations(S, n_elems))
213
n_combs = binomial(size, n_elems)
214
for i in [0..n_combs-1]:
215
combs[i] = list(combs[i])
216
powerset.extend(combs)
217
return(powerset)
218
219
def make_tsscpp_row(n, i):
220
"""
221
make_tsscpp_row(n,i)
222
223
Intermediate generator used in finding all TSSCPP's
224
of order n. This function takes the order of a TSSCPP
225
and a row number i and uses an iterator whose elements
226
are all possibilities for row i+1 of an n-by-n TSSCPP
227
array
228
229
Inputs
230
n: Order of the TSSCPP
231
i: Row number minus 1 (for purposes of looping)
232
233
Generates
234
r: Possible row i+1 for a TSSCPP array of order
235
n
236
"""
237
238
if i == n-1:
239
r = [0 for j in [1..n]]
240
r[i] = 2*n - 2*i - 1
241
yield(r)
242
return
243
244
trailing_vals = [-1 + 2*j for j in [1..n-i-1]]
245
P = powerset_ordered(trailing_vals)
246
P.reverse()
247
for subset in P:
248
subset.reverse()
249
r = [0 for j in [1..n]]
250
r[i] = 2*n - 2*i - 1
251
m = len(subset)
252
if m == 0:
253
yield(r)
254
else:
255
for k in [1..m]:
256
r[i+k] = subset[k-1]
257
yield(r)
258
259
def make_all_rows(n):
260
"""
261
make_all_rows(n)
262
263
Intermediate function that combines all lists of
264
possible rows for the TSCPP's of order n
265
266
Inputs
267
n: Order of the TSSCPP
268
269
Outputs
270
all_rows: A list where each element i (i from 0 to n-1)
271
is a list of all possible rows for row i+1 of
272
a TSSCPP array of order n
273
"""
274
275
all_rows = []
276
for i in [0 .. n-1]:
277
all_rows.append(list(make_tsscpp_row(n, i)))
278
return(all_rows)
279
280
def make_all_tsscpp_arrays(n):
281
"""
282
make_all_tsscpp_arrays(n):
283
284
Creates a list of all TSSCPP arrays of order n
285
286
Inputs
287
n: Order of the TSSCPP array
288
289
Outputs
290
all_mats: List of all TSSCPP arrays of order n
291
"""
292
293
all_mats = []
294
R = make_all_rows(n)
295
raw_mats = list(product(*R))
296
297
for M in raw_mats:
298
mat = []
299
for i in [0..n-1]:
300
mat.append(M[i])
301
302
i=1
303
while 1 <= i and i <= n-1:
304
j=i
305
while i <= j and j <= n-1:
306
if mat[i-1][j] != 0 and mat[i][j] == 0:
307
i = n
308
j = n
309
break
310
if mat[i-1][j] > mat[i][j]:
311
i = n
312
j = n
313
break
314
if i == n-1 and j == n-1:
315
all_mats.append(Matrix(ZZ, mat))
316
j = j+1
317
i = i+1
318
return(all_mats)
319