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
import os
2
3
4
############################################################
5
#### Reading in K Matrices
6
############################################################
7
8
9
def retrieve_mat(name, n):
10
if name == 'M' or name == 'M_inv' or name == 'K':
11
mat_file = open('tsscpp_data/tsscpp_{0}/{0}_{1}'.format(name, n), 'r')
12
mat_data = sage_eval(mat_file.readline())
13
mat = Matrix(QQ, mat_data)
14
mat_file.close()
15
return mat
16
else:
17
print("Error: first argument must be 'M', 'M_inv', or 'K'")
18
return
19
20
def make_K_mats(N):
21
K_mats = []
22
for n in [2 .. N]:
23
K_mats.append(retrieve_mat('K', n))
24
return K_mats
25
26
27
############################################################
28
#### Interpolating the Kernel K_n
29
############################################################
30
31
32
def make_denom(n, x, y):
33
x_max = ceil(x/2)
34
y_max = ceil(y/2)
35
return prod(4*n^2 - (2*m - 1)^2 for m in [1 .. x_max]) * prod(4*n^2 - (2*m - 1)^2 for m in [1 .. y_max])
36
37
# Creates the denominator of the conjectured formula for K_n, as a symbolic expression type
38
39
def make_Q_interpolated(x, y, alpha, beta, K_mats):
40
i = 2*(x-1) + alpha
41
j = 2*(y-1) + beta
42
43
# K_n(x,y)_(alpha, beta) corresponds to entry (i,j) of K_n
44
45
m = max(i,j)
46
n_min = ceil(1 + m/4)
47
N = len(K_mats) + 1
48
49
# n_min is the lowest index n for which K_n contains entry (i,j)
50
51
entries = []
52
for n in [n_min .. N]:
53
entries.append(K_mats[n-2][i-1, j-1])
54
55
# creates a sequence of entries K_n(x,y)_(alpha, beta) in n
56
57
interp_pts = [(n, 2^(2*(x+y)) * entries[n-n_min] * make_denom(n, x, y)) for n in [n_min .. N]]
58
R = QQ['x']
59
Q_expr = R.lagrange_polynomial(interp_pts)
60
return Q_expr
61
62
# Creates the polynomial Q_(alpha, beta, x, y) of the conjectured form of K_n, as a polynomial type in x
63
64
def make_rat_fn(x, y, alpha, beta, K_mats):
65
i = 2*(x-1) + alpha
66
j = 2*(y-1) + beta
67
68
var('n')
69
Q = make_Q_interpolated(x, y, alpha, beta, K_mats)
70
denom(n) = make_denom(n, x, y)
71
rat_fn(n) = 2^(-2*(x + y)) * Q(n) / denom(n)
72
73
return rat_fn.simplify_rational()
74
75
def make_K_interpolated(K_mats):
76
N = len(K_mats) + 1
77
x_max = floor((2*N - 9) / 5)
78
79
# x_max is the greatest index x for which K_n(x,x) can be interpolated, using the data from K_mats
80
81
K_interpolated = Matrix(SR, 2*x_max)
82
for x in [1 .. x_max]:
83
for y in [x .. x_max]:
84
if x == y:
85
alpha = 1
86
beta = 2
87
i = 2*(x-1) + alpha
88
j = 2*(y-1) + beta
89
K_interpolated[i-1, j-1] = make_rat_fn(x, y, alpha, beta, K_mats)
90
else:
91
for alpha in [1,2]:
92
for beta in [1,2]:
93
i = 2*(x-1) + alpha
94
j = 2*(y-1) + beta
95
K_interpolated[i-1, j-1] = make_rat_fn(x, y, alpha, beta, K_mats)
96
if x % 5 == 0:
97
print('x={0} completed'.format(x))
98
99
return K_interpolated - K_interpolated.transpose()
100
101
102
############################################################
103
#### Limits of Rational Functions
104
############################################################
105
106
107
def leading_degree(poly):
108
num_terms = len(poly.coefficients())
109
return(poly.coefficients()[num_terms-1][1])
110
111
def leading_coeff(poly):
112
num_terms = len(poly.coefficients())
113
return(poly.coefficients()[num_terms-1][0])
114
115
def rat_limit(rat):
116
num = rat.numerator()
117
den = rat.denominator()
118
if leading_degree(num) < leading_degree(den):
119
return 0
120
elif leading_degree(num) == leading_degree(den):
121
return leading_coeff(num) / leading_coeff(den)
122
else:
123
pm = sgn(leading_coeff(num) / leading_coeff(den))
124
return(pm * oo)
125
126
127
############################################################
128
#### FIXME
129
############################################################
130
131
132
def write_M_infinity(N, path):
133
"""
134
write_M_infinity(N, path)
135
136
Takes a positive integer N (large in practice) and creates the matrix
137
M_N, which is written to a file
138
139
Arguments
140
N: size of the matrix M_N to be calculated. Note that if N is odd,
141
then N is rounded to the next even number so that the indexing
142
of M_N starts at delta = 0
143
path: directory path in which to write
144
"""
145
146
N_next_even = 2 * ceil(N/2)
147
M_infinity = make_Mn(N_next_even)
148
149
file_name = 'M_infinity_trunc_{0}'.format(N_next_even)
150
text_file = open(os.path.join(path, file_name), 'w')
151
text_file.write(str(mat_to_list(M_infinity)))
152
text_file.close()
153
154
print('M_{0} successfully written'.format(N_next_even))
155
return()
156
157
def read_M_infinity(N, path):
158
"""
159
read_M_infinity(N, path)
160
161
Reads in the matrix M_N (created by read_M_infinity(N, path))
162
as a list of lists
163
164
Arguments
165
N: size of the matrix M_N to read in. Specifically, this function
166
reads the file created by make_M_infinity(N, path)
167
path: directory path containing the file to read
168
"""
169
170
N_next_even = 2 * ceil(N/2)
171
file_name = 'M_infinity_trunc_{0}'.format(N_next_even)
172
text_file = open(os.path.join(path, file_name), 'r')
173
return(sage_eval(text_file.readline()))
174
175
def make_M_infinity_submat(n, L):
176
"""
177
make_M_infinity_submat(n, L)
178
179
Creates the matrix M_n from a list L of the entries of
180
M_infinity
181
182
Arguments:
183
n: order of the matrix M_n
184
L: list of lists containing the data of M_infinity (part of
185
this data, more precisely)
186
"""
187
delta = n % 2
188
return(Matrix(ZZ, L)[delta:n, delta:n])
189