Shared2018-09-20-074703.ipynbOpen in CoCalc
from lie_algebra_multiplicity import *
def WeightsWithMultiplicity1InG2(l):
tot = 3 * l - 1
if tot < 0:
return []
else:
m1 = 0
m2 = 0
solns = []
if tot % 3 == 0:
m2 = tot / 3
elif tot % 3 == 1:
m1 = 2
m2 = (tot - 4) / 3
elif tot % 3 == 2:
m1 = 1
m2 = (tot - 2) / 3

while m1 >= 0 and m2 >= 0:
solns.append([m1,m2])
m1 += 3
m2 -= 2

return solns

def getAltSetsG(l):
weights = WeightsWithMultiplicity1InG2(l)
altsets = [findAltSet("G2", lamb = [0, l], mu = weight, simple = False) for weight in weights]
return altsets

def multCheckG(l):
weights = WeightsWithMultiplicity1InG2(l)
mults = [calculateMultiplicity("G2", lamb = [0,l], mu = weight, q_analog = True, simple=False) for weight in weights]
return mults

test = 1
print WeightsWithMultiplicity1InG2(test)
print getAltSetsG(test)
print multCheckG(test)

#getAltSetsG(1000)

from lie_algebra_multiplicity import *
def noElementsGreaterThan(arr, maxVal):
for i in arr:
if i > maxVal:
return False

return True

def countIndices(partition, r):
ret = [0 for i in range(0,r)]
for i in partition:
ret[i-1] += 1

return ret

def WeightsWithMultiplicity1InA(r, l):
mod = r+1
multiple = l / mod
distance = l % mod
all_weights = []

while multiple >= 0:
partitions = [partition for partition in Partitions(distance).list() if noElementsGreaterThan(partition, r)]
weights = [countIndices(partition, r) for partition in partitions]
all_weights = all_weights + weights  # this is not the best way, but I'll fix it later
multiple -= 1
distance += mod

return all_weights

def getAltSetsA(r, l):
weights = WeightsWithMultiplicity1InA(r, l)
altsets = [findAltSet("A" + str(r), lamb = [l], mu = weight, simple = False) for weight in weights]
return altsets

def multCheckA(r, l):
weights = WeightsWithMultiplicity1InA(r, l)
mults = [calculateMultiplicity("A" + str(r), lamb = [l], mu = weight, q_analog = True, simple=False) for weight in weights]
return mults

test_l = 12
test_r = 3
print WeightsWithMultiplicity1InA(test_r, test_l)
#print multCheckA(test_r, test_l)
print getAltSetsA(test_r, test_l)

[[0, 0, 0], [1, 0, 1], [0, 2, 0], [2, 1, 0], [4, 0, 0], [0, 1, 2], [2, 0, 2], [1, 2, 1], [3, 1, 1], [5, 0, 1], [0, 4, 0], [2, 3, 0], [4, 2, 0], [6, 1, 0], [8, 0, 0], [0, 0, 4], [1, 1, 3], [3, 0, 3], [0, 3, 2], [2, 2, 2], [4, 1, 2], [6, 0, 2], [1, 4, 1], [3, 3, 1], [5, 2, 1], [7, 1, 1], [9, 0, 1], [0, 6, 0], [2, 5, 0], [4, 4, 0], [6, 3, 0], [8, 2, 0], [10, 1, 0], [12, 0, 0]] [[1, s2, s3, s2*s3, s3*s2, s2*s3*s2], [1, s2, s3, s2*s3, s3*s2, s2*s3*s2], [1, s2, s3, s2*s3, s3*s2, s2*s3*s2], [1, s2, s3, s2*s3, s3*s2, s2*s3*s2], [1, s2, s3, s2*s3, s3*s2, s2*s3*s2], [1, s2, s3, s2*s3], [1, s2, s3, s2*s3], [1, s2, s3, s2*s3], [1, s2, s3, s2*s3], [1, s2, s3, s2*s3], [1, s2, s3, s2*s3], [1, s2, s3, s2*s3], [1, s2, s3, s2*s3], [1, s2, s3, s2*s3], [1, s2, s3, s2*s3], [1, s2], [1, s2], [1, s2], [1, s2], [1, s2], [1, s2], [1, s2], [1, s2], [1, s2], [1, s2], [1, s2], [1, s2], [1], [1], [1], [1], [1], [1], [1]]








def allEvenElements(arr):
for i in arr:
if i % 2 == 1:
return False

return True

def WeightsWithMultiplicity1InB(r, l):
if r < 2:
return []
tot = l - 1
m_r = int((tot * 2) / r)
m_r = m_r if m_r % 2 == 0 else m_r - 1
all_weights = []

while m_r >= 0:
sub_tot = int(tot - ((r * m_r)/2)) # this is always an integer, but sage automatically casts some things and causes issues with partitioning
partitions = [partition for partition in Partitions(sub_tot).list() if noElementsGreaterThan(partition, r-1)]
weights = [countIndices(partition, r-1) for partition in partitions]
weights = [weight + [m_r] for weight in weights if allEvenElements(weight)]
all_weights = all_weights + weights  # this is not the best way, but I'll fix it later
m_r -= 2

return all_weights

def getAltSetsB(r, l):
weights = WeightsWithMultiplicity1InB(r, l)
altsets = [findAltSet("B" + str(r), lamb = [l], mu = weight, simple = False) for weight in weights]
return altsets

def multCheckB(r, l):
weights = WeightsWithMultiplicity1InB(r, l)
mults = [calculateMultiplicity("B" + str(r), lamb = [l], mu = weight, q_analog = False, simple=False) for weight in weights]
return mults

test_r = 7
test_l = 8
print WeightsWithMultiplicity1InB(test_r, test_l)
print multCheckB(test_r, test_l)
print getAltSetsB(test_r, test_l)

--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-1-85265a087ee4> in <module>() 36 test_r = Integer(7) 37 test_l = Integer(8) ---> 38 print WeightsWithMultiplicity1InB(test_r, test_l) 39 print multCheckB(test_r, test_l) 40 print getAltSetsB(test_r, test_l) <ipython-input-1-85265a087ee4> in WeightsWithMultiplicity1InB(r, l) 16 while m_r >= Integer(0): 17 sub_tot = int(tot - ((r * m_r)/Integer(2))) # this is always an integer, but sage automatically casts some things and causes issues with partitioning ---> 18 partitions = [partition for partition in Partitions(sub_tot).list() if noElementsGreaterThan(partition, r-Integer(1))] 19 weights = [countIndices(partition, r-Integer(1)) for partition in partitions] 20 weights = [weight + [m_r] for weight in weights if allEvenElements(weight)] NameError: global name 'noElementsGreaterThan' is not defined