Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
205 views
in Technique[技术] by (71.8m points)

python - Acessing elements of permutation group in sagemath

if I consider an element of a permutation group in sagemath, for example SymmetricGroup(7).list()[1900],

which is (1,6)(2,5,4)(3,7),

I can get the cycles like elements from a list, so

SymmetricGroup(7).list()[1900][1],

will return (2,5,4).

However, I do not find a way, to get the elements of this object, as it looks like a tuple, but actually it is not, as

SymmetricGroup(7).list()[1900][1][1]

gives the error "list index out of range", instead of returning 5. Does somebody know, how I can get direct access to the entries of the cycle?

Thank you in advance.

question from:https://stackoverflow.com/questions/65836969/acessing-elements-of-permutation-group-in-sagemath

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I used tab-completion to find the method cycle_tuples:

sage: a = SymmetricGroup(7).list()[1900]                                                  
sage: a                                                                                   
(1,6)(2,5,4)(3,7)
sage: a.cycles()                                                                          
[(1,6), (2,5,4), (3,7)]
sage: type(a.cycles()[1]) # not what we want
<class 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement'>
sage: a.cycle_tuples()
[(1, 6), (2, 5, 4), (3, 7)]
sage: type(a.cycle_tuples()[1]) # what we want!
<class 'tuple'>
sage: b = a.cycle_tuples()[1]
sage: b
(2, 5, 4)
sage: b[1]
5

(By "using tab-completion," I mean typing "a." and then hitting the TAB key.) cycle_tuples is documented here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...