from sage.all import *
from Weight import Weight
from PartitionTree import PartitionTree
import __future__
import sys
import resource
count = []
# Constants Declaration
bChangeA4 = matrix([[1, 0, 0, 0, 0],
[-1, 1, 0, 0, 0],
[0, -1, 1, 0, 0],
[0, 0, -1, 1, 0],
[0, 0, 0, -1, 1]]).inverse();
bChangeG2 = matrix([[2, 1, 0],
[1, 0, 0],
[1, 1, 1]])
bChangeF4 = matrix([[1, 1, 0, 0],
[2, 1, 1, 0],
[3, 1, 1, 1],
[2, 0, 0, 0]])
bChangeE6 = matrix([[0, 0, 0, 0, 0, -2, 0, 0],
[ 1/2, 1/2, 1/2, 1/2, 1/2, -3/2, 0, 0],
[-1/2, 1/2, 1/2, 1/2, 1/2, -5/2, 0, 0],
[ 0, 0, 1, 1, 1, -3, 0, 0],
[ 0, 0, 0, 1, 1, -2, 0, 0],
[ 0, 0, 0, 0, 1, -1, 0, 0],
[ 0, 0, 0, 0, 0, -1, 1, 0],
[ 0, 0, 0, 0, 0, 1, 0, 1]])
bChangeE7 = matrix([[ 0, 0, 0, 0, 0, 0, -2, 0],
[ 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, -2, 0],
[-1/2, 1/2, 1/2, 1/2, 1/2, 1/2, -3, 0],
[ 0, 0, 1, 1, 1, 1, -4, 0],
[ 0, 0, 0, 1, 1, 1, -3, 0],
[ 0, 0, 0, 0, 1, 1, -2, 0],
[ 0, 0, 0, 0, 0, 1, -1, 0],
[ 0, 0, 0, 0, 0, 0, 1, 1]])
bChangeE8 = matrix([[ 0, 0, 0, 0, 0, 0, 0, 2],
[ 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 5/2],
[-1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 7/2],
[ 0, 0, 1, 1, 1, 1, 1, 5],
[ 0, 0, 0, 1, 1, 1, 1, 4],
[ 0, 0, 0, 0, 1, 1, 1, 3],
[ 0, 0, 0, 0, 0, 1, 1, 2],
[ 0, 0, 0, 0, 0, 0, 1, 1]])
basisChangeMatrices = {"G2": bChangeG2, "F4": bChangeF4, "E6": bChangeE6, "E7": bChangeE7, "E8": bChangeE8, "A4":bChangeA4}
numOfRoots = {"G2": 6, "F4": 4, "E6": 36, "E7": 63, "E8": 120}
vectorDimension = {"G2": 3, "F4": 4, "E6": 8, "E7": 8, "E8": 8}
num = 0
def getPartition(name, root):
# used to change the basis from the standard basis of R^n to simple roots
changeBasis = basisChangeMatrices[name]
# this collect all of the positive roots for use in partitioning
poset = [vector(list(Eval(x))) for x in RootSystem(name).ambient_space().positive_roots()]
alphaPoset = [Weight(list(changeBasis * x)) for x in poset]
for x in alphaPoset:
print(x)
tree = PartitionTree(Weight(root), alphaPoset, 0, 0);
tree.cleanTree()
parts = []
tree.getPartitions(parts);
for x in parts:
print(x)
print(len(parts))
def Eval(string):
return eval(compile(str(string), '<string>', 'eval', __future__.division.compiler_flag))
def computeMq(name, lamb, mu):
num = 0
success = 0
# initialize constants and vector space for the lie algebra
lie_algebra = RootSystem(name).ambient_space()
weyl_group = WeylGroup(name, prefix = "s")
# equation is a vector that will hold the coefficients of Mq
equation = vector([0 for i in range(0, numOfRoots[name] + 25)])
# used to change the basis from the standard basis of R^n to simple roots
changeBasis = basisChangeMatrices[name]
# this collect all of the positive roots for use in partitioning
poset = [vector(list(Eval(x))) for x in RootSystem(name).ambient_space().positive_roots()]
alphaPoset = [Weight(list(changeBasis * x)) for x in poset]
alphaPoset = sorted(alphaPoset, key = lambda(x): x.height())
#sys.exit()
# if lambda is not specified, the highest root is used
if lamb == "none":
lamb = lie_algebra.highest_root()
else:
lamb = changeBasis.inverse() * vector(lamb)
lamb = weyl_group.domain()(list(eval(str(lamb))))
# if mu is not specified, 0 vector is used
if mu == "none":
mu = weyl_group.domain()([0 for i in range(0, vectorDimension[name])])
else:
mu = changeBasis.inverse() * vector(mu)
mu = weyl_group.domain()(list(eval(str(mu))))
# rho is 1/2 the sum of the positive roots
rho = lie_algebra.rho()
i = -1
for elm in weyl_group:
if (elm.length() > 8):
continue
i = i + 1
# expression in partition function
res = elm.action(lamb + rho) - (mu + rho)
#change basis from standard basis to simple roots
res = vector(list(Eval(res)))
res = changeBasis * res
# make a root object out of the result, check if it can be partitioned
r = Weight(list(eval(str(res))))
if not (r.isNegative() or r.hasFraction()):
print("result: " + str(r))
# root can be partitioned, find its Pq, add it to the sum
tree = PartitionTree(r, alphaPoset, 0, 0)
tree.cleanTree()
Pq = [0 for x in range (0, numOfRoots[name] + 25)]
tree.generatePq(Pq)
# save results to a table
count.append([str(elm), str(elm.length()), str(r), str(Pq)])
Pq = ((-1)**elm.length()) * vector(Pq)
equation = equation + Pq
num += ((-1)**elm.length()) * tree.countPartitions()
#print("Success: " + str(res))
del(tree)
del(Pq)
#else:
#print("Failure: " + str(res))
del(res)
del(r)
return equation
%time
computeMq("E7", "none", "none")
%time
f = open("E7 results.txt", "w+")
for x in count:
f.write(str(x) + "\n")
f.close()