diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pxd b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pxd index e9c99789df1..b3081e0b506 100644 --- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pxd +++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pxd @@ -9,6 +9,7 @@ from sage.groups.perm_gps.partn_ref.data_structures cimport OrbitPartition, PartitionStack from sage.libs.gap.element cimport GapElement, GapElement_Permutation +from sage.structure.parent cimport Parent cdef extern from "refinement_generic.h": cdef long *global_refine_vals_array @@ -35,6 +36,7 @@ cdef class LabelledBranching: cdef int *father cdef int *act_perm cpdef GapElement group, ClosureGroup + cdef Parent sym_gp cdef bint has_empty_intersection(self, PartitionStack * part) cpdef add_gen(self, GapElement_Permutation gen) diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx index 998febe0839..f46cbfdda6b 100644 --- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx +++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx @@ -334,11 +334,13 @@ cdef class LabelledBranching: sage: L = LabelledBranching(3) """ from sage.libs.gap.libgap import libgap + from sage.groups.perm_gps.permgroup_named import SymmetricGroup self.n = n self.group = libgap.eval("Group(())") self.ClosureGroup = libgap.eval("ClosureGroup") self.father = < int *> sig_malloc(n * sizeof(int)) + self.sym_gp = SymmetricGroup(self.n) if self.father is NULL: raise MemoryError('allocating LabelledBranching') self.act_perm = < int *> sig_malloc(n * sizeof(int)) @@ -433,8 +435,7 @@ cdef class LabelledBranching: [(1,2,3)] """ from sage.libs.gap.libgap import libgap - - return libgap.SmallGeneratingSet(self.group).sage() + return libgap.SmallGeneratingSet(self.group).sage(parent=self.sym_gp) def get_order(self): r""" diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx index 63e3cab4391..8d2fc467aad 100644 --- a/src/sage/libs/gap/libgap.pyx +++ b/src/sage/libs/gap/libgap.pyx @@ -49,14 +49,24 @@ equivalent:: sage: libgap.eval('5/3 + 7*E(3)').sage() 7*zeta3 + 5/3 - sage: generators = libgap.AlternatingGroup(4).GeneratorsOfGroup().sage() + sage: gens_of_group = libgap.AlternatingGroup(4).GeneratorsOfGroup() + sage: generators = gens_of_group.sage() sage: generators # a Sage list of Sage permutations! - [(1,2,3), (2,3,4)] + [[2, 3, 1], [1, 3, 4, 2]] sage: PermutationGroup(generators).cardinality() # computed in Sage 12 sage: libgap.AlternatingGroup(4).Size() # computed in GAP 12 +We can also specify which group in Sage the permutations should +consider themselves as elements of when converted to Sage:: + + sage: A4 = groups.permutation.Alternating(4) + sage: generators = gens_of_group.sage(parent=A4); generators + [(1,2,3), (2,3,4)] + sage: all(gen.parent() is A4 for gen in generators) + True + So far, the following GAP data types can be directly converted to the corresponding Sage datatype: