Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'u/stumpc5/have_libgap_permutation_to_sage_use_permutati…
Browse files Browse the repository at this point in the history
…on_instead_of_permutation_group_element' of git://trac.sagemath.org/sage into u/tscrim/libgap_to_sage_permutation_construction-25609
  • Loading branch information
Travis Scrimshaw committed Oct 2, 2018
2 parents ca255bb + 18f93ed commit 0a25f1a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/sage/groups/perm_gps/permgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
- Javier Lopez Pena (2013): Added conjugacy classes.
- Sebastian Oehms (2018): added _coerce_map_from_ in order to use isomorphism coming up with as_permutation_group method (Trac #25706)
- Christian Stump (2018): Added alternative implementation of strong_generating_system directly using GAP.
REFERENCES:
Expand Down
22 changes: 18 additions & 4 deletions src/sage/libs/gap/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ from sage.structure.sage_object cimport SageObject
from sage.structure.parent import Parent
from sage.rings.all import ZZ, QQ, RDF

from sage.groups.perm_gps.permgroup_element cimport PermutationGroupElement
from sage.combinat.permutation import Permutation

decode_type_number = {
libGAP_T_INT: 'T_INT (integer)',
libGAP_T_INTPOS: 'T_INTPOS (positive integer)',
Expand Down Expand Up @@ -2786,24 +2789,35 @@ cdef class GapElement_Permutation(GapElement):
<type 'sage.libs.gap.element.GapElement_Permutation'>
"""

def sage(self):
def sage(self, parent=None):
r"""
Return the Sage equivalent of the :class:`GapElement`
If the permutation group is given as parent, this method is
*much* faster.
EXAMPLES::
sage: perm_gap = libgap.eval('(1,5,2)(4,3,8)'); perm_gap
(1,5,2)(3,8,4)
sage: perm_gap.sage()
[5, 1, 8, 3, 2, 6, 7, 4]
sage: type(_)
<class 'sage.combinat.permutation.StandardPermutations_all_with_category.element_class'>
sage: perm_gap.sage(PermutationGroup([(1,2),(1,2,3,4,5,6,7,8)]))
(1,5,2)(3,8,4)
sage: type(_)
<type 'sage.groups.perm_gps.permgroup_element.PermutationGroupElement'>
"""
from sage.groups.perm_gps.permgroup_element import PermutationGroupElement
libgap = self.parent()
return PermutationGroupElement(libgap.ListPerm(self).sage())
cdef PermutationGroupElement one_c

libgap = self.parent()
lst = libgap.ListPerm(self)

if parent is None:
return Permutation(lst.sage(), check_input=False)
else:
return parent.one()._generate_new_GAP(lst)

############################################################################
### GapElement_Record ######################################################
Expand Down

0 comments on commit 0a25f1a

Please sign in to comment.