-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasis-functions.sage
More file actions
50 lines (40 loc) · 1.52 KB
/
basis-functions.sage
File metadata and controls
50 lines (40 loc) · 1.52 KB
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
def gen_ring(n):
# Use strings, not SR vars; use a graded order for nicer behavior in Singular
names = [f"x{i}" for i in range(1, n+1)] + [f"y{i}" for i in range(1, n+1)]
R = PolynomialRing(QQ, names, order='degrevlex')
x = R.gens()[:n]
y = R.gens()[n:]
return R, x, y
def powersum(x, y, i, j):
n = len(x)
return sum(x[k]**i * y[k]**j for k in range(n))
def gen_ideal(R, x, y):
n = len(x)
gens = [powersum(x, y, i, j) for i in range(2*n) for j in range(2*n)]
return R.ideal(gens[1:])
def Poly2Vec(MonList,pol):
"""This function converts polymonial pol into the vector by extracting coeffients in front of monomials from the list MonList."""
return([pol.monomial_coefficient(z) for z in MonList])
def gb_init(n):
return gen_ideal(n).normal_basis()
def test_rank(n):
ListV = [Poly2Vec(gb_init(n), x.reduce(gen_ideal(n))) for x in test(n)]
return matrix(ListV)
def gen_m(R, x, y, l):
n = len(l)
return matrix([[x[i]^(l[j][0])*y[i]^(l[j][1]) for j in range(n)] for i in range(n)])
def gen_det(R, x, y, l):
return gen_m(R, x, y, l).determinant()
def dinv_code(D):
n = D.semilength()
a = D.to_area_sequence()
return [len([j for j in range(i+1,n) if a[j] == a[i] or a[j] == a[i]-1]) for i in range(n-1)]+[0]
def catdet(R, x, y):
n = len(x)
for D in DyckWords(n):
a = D.to_area_sequence()
aa = dinv_code(D)
yield gen_det(R, x, y, list(zip(aa,a)))
def alternate_ideal(R, x, y):
n = len(x)
return R.ideal(list(catdet(R, x, y)))