NCGE Python Code
From Drorbn
Jump to navigationJump to search
class Perm(object):
def __init__(self, L): if set(range(1,len(L) + 1)) == set(L): self.n = len(L) self.mapping = {} pivot_called = False for i in range(self.n): if not pivot_called: if L[i] != i+1: self.pivot = i+1 pivot_called = True if not pivot_called: self.pivot = self.n self.mapping[i+1] = L[i] def __nonzero__(self): return self.pivot != self.n def __mul__(self,other):
if self.n == other.n: L = [] for i in range(1,self.n+1): L += [self.mapping[other.mapping[i]]] return Perm(L) def inv(self): L = [] inverted = {} for i in range(1,self.n + 1): inverted[self.mapping[i]] = i for j in range(1,self.n + 1): L += [inverted[j]] return Perm(L)
def e(n):
return Perm(range(1,n+1))
def gen_subgroup_order(L):
homogenous_n = True perm1 = L[0] for perm in L: if perm.n != perm1.n: homogenous_n = False break if homogenous_n: X = L[:] n = perm1.n occupied = {} for k in range(1,n+1): occupied[(k,k)] = e(n) def feed(perm,Y,table): if bool(perm): i = perm.pivot j = perm.mapping[perm.pivot] if (i,j) not in occupied.keys(): table[(i,j)] = perm else: sigma = table[(i,j)] Y += [(sigma.inv())*perm] for perm in X: feed(perm,X,occupied) old = 0 new = len(occupied.keys()) while old != new: X = [] perms = occupied.values() for p1 in perms: for p2 in perms: if bool(p1) and bool(p2): X += [p1*p2] for perm in X: feed(perm,X,occupied) old, new = new, len(occupied.keys()) order = 1 for i in range(1,n+1): order *= len([pair for pair in occupied.keys() if pair[0] == i]) return order
g1 = Perm([1,2,3,4,12,22,7,8,6,11,21,28,13,14,15,16,17,18,5,10,20,27,23,24,25,26,9,19,29,30,31,32])
g2 = Perm([1,2,13,23,5,6,7,4,9,10,11,12,30,14,15,16,17,3,19,20,21,22,29,24,25,26,27,28,8,18,31,32])
g3 = Perm([14,24,3,4,5,6,2,8,9,10,11,12,13,32,16,26,1,18,19,20,21,22,23,31,15,25,27,28,29,30,7,17])
g4 = Perm([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,22,23,24,25,26,17,18,19,20,21,32,31,30,29,28,27])
print gen_subgroup_order([g1,g2,g3,g4])