h functions

124 days ago by erik.insko@gmail.com

n = 4 l1 = range(1,n+1) print l1 lists=[l1] for index in range(n-1): while lists[-1][-(index+2)]<4: newlist=lists[-1][:] newlist[-(index+2)] = newlist[-(index+2)]+1 lists.append(newlist) print lists 
       
[1, 2, 3, 4]
[[1, 2, 3, 4], [1, 2, 4, 4], [1, 3, 4, 4], [1, 4, 4, 4], [2, 4, 4, 4],
[3, 4, 4, 4], [4, 4, 4, 4]]
[1, 2, 3, 4]
[[1, 2, 3, 4], [1, 2, 4, 4], [1, 3, 4, 4], [1, 4, 4, 4], [2, 4, 4, 4], [3, 4, 4, 4], [4, 4, 4, 4]]
h=range(1,n+1) lists=[h] for h in lists: for i in range(n-1): if h[i]<h[i+1]: j=h[:] j[i]=j[i]+1 lists.append(j) #print lists lists2=[] for item in lists: if item not in lists2: lists2.append(item) print lists2 
       
[[1, 2, 3, 4], [2, 2, 3, 4], [1, 3, 3, 4], [1, 2, 4, 4], [2, 3, 3, 4],
[2, 2, 4, 4], [1, 3, 4, 4], [3, 3, 3, 4], [2, 3, 4, 4], [1, 4, 4, 4],
[3, 3, 4, 4], [2, 4, 4, 4], [3, 4, 4, 4], [4, 4, 4, 4]]
[[1, 2, 3, 4], [2, 2, 3, 4], [1, 3, 3, 4], [1, 2, 4, 4], [2, 3, 3, 4], [2, 2, 4, 4], [1, 3, 4, 4], [3, 3, 3, 4], [2, 3, 4, 4], [1, 4, 4, 4], [3, 3, 4, 4], [2, 4, 4, 4], [3, 4, 4, 4], [4, 4, 4, 4]]
#Enter in the length of the permutations you want to consider n=4; #you can enter in any Hessenberg function below ##################### listh() ############################################################# #input: n #output: list of all h functions ########################################################################################### def listh(n): h=range(1,n+1) lists=[h] for h in lists: for i in range(n-1): if h[i]<h[i+1]: j=h[:] j[i]=j[i]+1 lists.append(j) lists2=[] for item in lists: if item not in lists2: lists2.append(item) #print lists2 return(lists2) ########################################################################################### ############## Hesscycle(n,h) #################################################################### # input: n and a Hessenberg function h # output: a vector containing the cycle types of the Hessenberg permutations ################################################################################################# def Hesscycle(n,h): perm = permutations(n); #this just lists the permutations of length n cycle=[] for item in perm: cycle.append([item ,item.to_cycles()] ) permcycle=[] for item in cycle: permdata=[] for item2 in item[1]: if len(item2)>1: permdata.append(item2) #print item[0],item2 permcycle.append([item[0], permdata]) badlist=[] for item in permcycle: for cycle in item[1]: for index in range(len(cycle)-1): if h[cycle[index]-1]<cycle[index+1]: #print item, cycle badlist.append(item) Hessenbergpermutations=[] for item in permcycle: if item not in badlist: Hessenbergpermutations.append(item) print "Hessenberg Function", h cycletypes=[] for item in Hessenbergpermutations: cycletypes.append(item[0].cycle_type()) cycletypes=list(set(cycletypes)) cyclenumber=[] for index in range(len(cycletypes)): cyclenumber.append([cycletypes[index]]) for item2 in Hessenbergpermutations: if item2[0].cycle_type() == cycletypes[index]: cyclenumber[index].append(item2[1]) vec=[] for item in cyclenumber: vec.append(len(item)-1) v=vec return(v) ####################################################################################################################### lists=listh(n) for h in lists: print Hesscycle(n,h) 
       
Hessenberg Function [1, 2, 3, 4]
[1]
Hessenberg Function [2, 2, 3, 4]
[1, 1]
Hessenberg Function [1, 3, 3, 4]
[1, 1]
Hessenberg Function [1, 2, 4, 4]
[1, 1]
Hessenberg Function [2, 3, 3, 4]
[1, 1, 2]
Hessenberg Function [2, 2, 4, 4]
[1, 1, 2]
Hessenberg Function [1, 3, 4, 4]
[1, 1, 2]
Hessenberg Function [3, 3, 3, 4]
[1, 2, 3]
Hessenberg Function [2, 3, 4, 4]
[1, 1, 2, 1, 3]
Hessenberg Function [1, 4, 4, 4]
[1, 2, 3]
Hessenberg Function [3, 3, 4, 4]
[1, 2, 4, 1, 4]
Hessenberg Function [2, 4, 4, 4]
[1, 2, 4, 1, 4]
Hessenberg Function [3, 4, 4, 4]
[1, 4, 6, 2, 5]
Hessenberg Function [4, 4, 4, 4]
[1, 6, 8, 3, 6]
Hessenberg Function [1, 2, 3, 4]
[1]
Hessenberg Function [2, 2, 3, 4]
[1, 1]
Hessenberg Function [1, 3, 3, 4]
[1, 1]
Hessenberg Function [1, 2, 4, 4]
[1, 1]
Hessenberg Function [2, 3, 3, 4]
[1, 1, 2]
Hessenberg Function [2, 2, 4, 4]
[1, 1, 2]
Hessenberg Function [1, 3, 4, 4]
[1, 1, 2]
Hessenberg Function [3, 3, 3, 4]
[1, 2, 3]
Hessenberg Function [2, 3, 4, 4]
[1, 1, 2, 1, 3]
Hessenberg Function [1, 4, 4, 4]
[1, 2, 3]
Hessenberg Function [3, 3, 4, 4]
[1, 2, 4, 1, 4]
Hessenberg Function [2, 4, 4, 4]
[1, 2, 4, 1, 4]
Hessenberg Function [3, 4, 4, 4]
[1, 4, 6, 2, 5]
Hessenberg Function [4, 4, 4, 4]
[1, 6, 8, 3, 6]
C =SymmetricGroup(4).character_table() h print C print matrix(v).transpose() s = PermutationGroupElement([5,1,3,4,2]).matrix() print s t = PermutationGroupElement([1,5,4,3,2]).matrix() C = s*C print C m = matrix(v).transpose() m = t* m print "Answer" print C*m 
       
[ 1 -1  1  1 -1]
[ 3 -1 -1  0  1]
[ 2  0  2 -1  0]
[ 3  1 -1  0 -1]
[ 1  1  1  1  1]
[1]
[6]
[8]
[3]
[6]
[0 0 0 0 1]
[1 0 0 0 0]
[0 0 1 0 0]
[0 0 0 1 0]
[0 1 0 0 0]
[ 1  1  1  1  1]
[ 1 -1  1  1 -1]
[ 2  0  2 -1  0]
[ 3  1 -1  0 -1]
[ 3 -1 -1  0  1]
Answer
[24]
[ 0]
[ 0]
[ 0]
[ 0]
[ 1 -1  1  1 -1]
[ 3 -1 -1  0  1]
[ 2  0  2 -1  0]
[ 3  1 -1  0 -1]
[ 1  1  1  1  1]
[1]
[6]
[8]
[3]
[6]
[0 0 0 0 1]
[1 0 0 0 0]
[0 0 1 0 0]
[0 0 0 1 0]
[0 1 0 0 0]
[ 1  1  1  1  1]
[ 1 -1  1  1 -1]
[ 2  0  2 -1  0]
[ 3  1 -1  0 -1]
[ 3 -1 -1  0  1]
Answer
[24]
[ 0]
[ 0]
[ 0]
[ 0]