Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This is a corrected version of the thought process provided by Max Alekseyev (it copies some of his code as well). I didn't realise Sagemath had so many built in features to manipulate groups, and there is a good chance that this approach could be substantially improved. However, it is fast enough for my purposes.

import sage.combinat.permutation as permutation

dP = [3,4,3,2,4]
n = len(dP)
S = SymmetricGroup(n)

s_dP = sorted(dP)     # Sorted list
# Fixed permutation that puts dP in the right order
p = S( Word(s_dP).standard_permutation() / Word(dP).standard_permutation() ) 

P = [] # List to store a generating set of permutations for the subgroup that fixes s_dP

at = 1 # Counter variable
for element in unique(s_dP):
    num = s_dP.count(element) # Number of times element appears in s_dP
    # We sum over integer partitions as they label conjugacy classes of the symmetric group;
    # thus they provide an easy way to get all generators of our desired subgroup
    for part in Partitions(num, max_length = 2).list():
        int_at=at
        cycle = []
        for comp in part:
            # Attach a cycle for each integer in the partition
            cycle += [ srange( int_at, int_at+comp ) ] 
            int_at += comp
        # Add the partition from the constructed cycles to our generating set
        P += [ permutation.from_cycles(n, cycle )] 
    at += num
G = S.subgroup(P)    # Subgroup that fix s_dP
perms = []
for q in G:
    perms += [Permutation( q * p )]

This is a corrected version of the thought process provided by Max Alekseyev (it copies some of his code as well). I didn't realise Sagemath had so many built in features to manipulate groups, and there is a good chance that this approach could be substantially improved. However, it is fast enough for my purposes.

import sage.combinat.permutation as permutation
from numpy import unique

dP = [3,4,3,2,4]
[1,1,1,3,3]
n = len(dP)
S = SymmetricGroup(n)
perms = []

s_dP = sorted(dP)     # Sorted sorted list
# Fixed permutation that puts dP in the right order
p = S( Word(s_dP).standard_permutation() / Word(dP).standard_permutation() ) 

)
P = [] # List to store a generating set of permutations for the subgroup that fixes s_dP

[]
at = 1 # Counter variable
for element in unique(s_dP):
    num = s_dP.count(element) # Number of times element appears in s_dP
    # We sum over integer partitions as they label conjugacy classes of the symmetric group;
    # thus they provide an easy way to get all generators of our desired subgroup
    P += [permutation.from_cycles(n,[srange(i+at,i+at+2)]) for part i in Partitions(num, max_length = 2).list():
        int_at=at
        cycle = []
        for comp in part:
            # Attach a cycle for each integer in the partition
            cycle += [ srange( int_at, int_at+comp ) ] 
            int_at += comp
        srange(num-1)] # Add the partition from the constructed cycles to our generating set
        P += [ permutation.from_cycles(n, cycle )] 
a generator
    at += num
G = S.subgroup(P)    # Subgroup subgroup that fix s_dP
perms = []
for q in G:
    perms += [Permutation( q * p )]

This is a corrected version of the thought process provided by Max Alekseyev (it copies some of his code as well). I didn't realise Sagemath had so many built in features to manipulate groups, and there is a good chance that this approach could be substantially improved. However, it is fast enough for my purposes.

import sage.combinat.permutation as permutation
from numpy import unique

dP = [1,1,1,3,3]
n = len(dP)
S = SymmetricGroup(n)
perms = []

s_dP = sorted(dP)     # sorted list
p = S( Word(s_dP).standard_permutation() / Word(dP).standard_permutation() )
P = []
at = 1 # Counter variable
for element in unique(s_dP):
    num = s_dP.count(element) # Number of times element appears in s_dP
    # Add a generator
    P += [permutation.from_cycles(n,[srange(i+at,i+at+2)]) for i in srange(num-1)] # Add a generator
srange(num-1)]
    at += num
G = S.subgroup(P)    # subgroup that fix s_dP
for q in G:
    perms += [Permutation( q * p )]