-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathp-core.sage.py
86 lines (69 loc) · 2.08 KB
/
p-core.sage.py
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
# This file was *autogenerated* from the file p-core.sage
from sage.all_cmdline import * # import sage library
_sage_const_1 = Integer(1); _sage_const_2 = Integer(2); _sage_const_0 = Integer(0)
import math
R = QQ['t']; (t,) = R._first_ngens(1)
K = R.fraction_field()
def pp(t,i):
return (_sage_const_1 -t**i)**(-i)
def cs(t,i):
return (_sage_const_1 -t**(_sage_const_2 *i-_sage_const_1 ))**(-i)*(_sage_const_1 -t**(_sage_const_2 *i))**(-i)
def generating_function(n,f,p):
return math.prod([f(t,i)/f(t**p,i)**p for i in range(n)])
def positivity_test(n,p):
counter = _sage_const_0
R = QQ['t']; (t,) = R._first_ngens(1)
for i in R(generating_function(n,p)).coefficients():
if i < _sage_const_0 :
return counter
counter += _sage_const_1
def cs_pp_gf(a,b,c,k):
s = SymmetricFunctions(QQ).s()
try:
return sum([s(p) for p in Partitions(k,max_part=a,length=b)]).expand(c)
except AttributeError:
print('emptyset')
return
def is_cs(pp):
return all([len(t) == len(set(t)) for t in pp.transpose()])
def cs_pp(a,b,c,k):
return [pp for pp in PlanePartitions([a,b,c]) if is_cs(pp) and pp.number_of_boxes()==k]
def helper(tab, i, t):
j = len(tab[i])-_sage_const_1
temp = tab[i][j]
tab[i][j] -= _sage_const_1
for k in range(t-_sage_const_1 ):
if i+_sage_const_1 < len(tab) and j < len(tab[i+_sage_const_1 ]):
if tab[i+_sage_const_1 ][j] == temp or tab[i+_sage_const_1 ][j] == temp-_sage_const_1 :
temp = tab[i+_sage_const_1 ][j]
tab[i+_sage_const_1 ][j] -= _sage_const_1
i += _sage_const_1
else:
try:
temp = tab[i][j-_sage_const_1 ]
tab[i][j-_sage_const_1 ] -= _sage_const_1
j -= _sage_const_1
except IndexError:
return None
return True
def one_peel(t, pp):
for i in range(len(pp.to_tableau())):
tab = [list(tup) for tup in pp.to_tableau()]
if helper(tab, i, t):
try:
temp = PlanePartition(tab)
if is_cs(temp):
return temp
else:
continue
except ValueError:
continue
raise Exception('no more hooks to remove')
def peel(t, pp):
q = pp
while True:
try:
q = one_peel(t, q)
print(q)
except:
return q