Companion to "Pfaffian Point Processes for Two Classes of Random Plane Partitions"
import os123############################################################4#### Reading in K Matrices5############################################################678def retrieve_mat(name, n):9if name == 'M' or name == 'M_inv' or name == 'K':10mat_file = open('tsscpp_data/tsscpp_{0}/{0}_{1}'.format(name, n), 'r')11mat_data = sage_eval(mat_file.readline())12mat = Matrix(QQ, mat_data)13mat_file.close()14return mat15else:16print("Error: first argument must be 'M', 'M_inv', or 'K'")17return1819def make_K_mats(N):20K_mats = []21for n in [2 .. N]:22K_mats.append(retrieve_mat('K', n))23return K_mats242526############################################################27#### Interpolating the Kernel K_n28############################################################293031def make_denom(n, x, y):32x_max = ceil(x/2)33y_max = ceil(y/2)34return 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])3536# Creates the denominator of the conjectured formula for K_n, as a symbolic expression type3738def make_Q_interpolated(x, y, alpha, beta, K_mats):39i = 2*(x-1) + alpha40j = 2*(y-1) + beta4142# K_n(x,y)_(alpha, beta) corresponds to entry (i,j) of K_n4344m = max(i,j)45n_min = ceil(1 + m/4)46N = len(K_mats) + 14748# n_min is the lowest index n for which K_n contains entry (i,j)4950entries = []51for n in [n_min .. N]:52entries.append(K_mats[n-2][i-1, j-1])5354# creates a sequence of entries K_n(x,y)_(alpha, beta) in n5556interp_pts = [(n, 2^(2*(x+y)) * entries[n-n_min] * make_denom(n, x, y)) for n in [n_min .. N]]57R = QQ['x']58Q_expr = R.lagrange_polynomial(interp_pts)59return Q_expr6061# Creates the polynomial Q_(alpha, beta, x, y) of the conjectured form of K_n, as a polynomial type in x6263def make_rat_fn(x, y, alpha, beta, K_mats):64i = 2*(x-1) + alpha65j = 2*(y-1) + beta6667var('n')68Q = make_Q_interpolated(x, y, alpha, beta, K_mats)69denom(n) = make_denom(n, x, y)70rat_fn(n) = 2^(-2*(x + y)) * Q(n) / denom(n)7172return rat_fn.simplify_rational()7374def make_K_interpolated(K_mats):75N = len(K_mats) + 176x_max = floor((2*N - 9) / 5)7778# x_max is the greatest index x for which K_n(x,x) can be interpolated, using the data from K_mats7980K_interpolated = Matrix(SR, 2*x_max)81for x in [1 .. x_max]:82for y in [x .. x_max]:83if x == y:84alpha = 185beta = 286i = 2*(x-1) + alpha87j = 2*(y-1) + beta88K_interpolated[i-1, j-1] = make_rat_fn(x, y, alpha, beta, K_mats)89else:90for alpha in [1,2]:91for beta in [1,2]:92i = 2*(x-1) + alpha93j = 2*(y-1) + beta94K_interpolated[i-1, j-1] = make_rat_fn(x, y, alpha, beta, K_mats)95if x % 5 == 0:96print('x={0} completed'.format(x))9798return K_interpolated - K_interpolated.transpose()99100101############################################################102#### Limits of Rational Functions103############################################################104105106def leading_degree(poly):107num_terms = len(poly.coefficients())108return(poly.coefficients()[num_terms-1][1])109110def leading_coeff(poly):111num_terms = len(poly.coefficients())112return(poly.coefficients()[num_terms-1][0])113114def rat_limit(rat):115num = rat.numerator()116den = rat.denominator()117if leading_degree(num) < leading_degree(den):118return 0119elif leading_degree(num) == leading_degree(den):120return leading_coeff(num) / leading_coeff(den)121else:122pm = sgn(leading_coeff(num) / leading_coeff(den))123return(pm * oo)124125126############################################################127#### FIXME128############################################################129130131def write_M_infinity(N, path):132"""133write_M_infinity(N, path)134135Takes a positive integer N (large in practice) and creates the matrix136M_N, which is written to a file137138Arguments139N: size of the matrix M_N to be calculated. Note that if N is odd,140then N is rounded to the next even number so that the indexing141of M_N starts at delta = 0142path: directory path in which to write143"""144145N_next_even = 2 * ceil(N/2)146M_infinity = make_Mn(N_next_even)147148file_name = 'M_infinity_trunc_{0}'.format(N_next_even)149text_file = open(os.path.join(path, file_name), 'w')150text_file.write(str(mat_to_list(M_infinity)))151text_file.close()152153print('M_{0} successfully written'.format(N_next_even))154return()155156def read_M_infinity(N, path):157"""158read_M_infinity(N, path)159160Reads in the matrix M_N (created by read_M_infinity(N, path))161as a list of lists162163Arguments164N: size of the matrix M_N to read in. Specifically, this function165reads the file created by make_M_infinity(N, path)166path: directory path containing the file to read167"""168169N_next_even = 2 * ceil(N/2)170file_name = 'M_infinity_trunc_{0}'.format(N_next_even)171text_file = open(os.path.join(path, file_name), 'r')172return(sage_eval(text_file.readline()))173174def make_M_infinity_submat(n, L):175"""176make_M_infinity_submat(n, L)177178Creates the matrix M_n from a list L of the entries of179M_infinity180181Arguments:182n: order of the matrix M_n183L: list of lists containing the data of M_infinity (part of184this data, more precisely)185"""186delta = n % 2187return(Matrix(ZZ, L)[delta:n, delta:n])188189