def __init__(self, generator_names, libgap_free_group=None): """ Python constructor. INPUT: - ``generator_names`` -- a tuple of strings. The names of the generators. - ``libgap_free_group`` -- a LibGAP free group or ``None`` (default). The LibGAP free group to wrap. If ``None``, a suitable group will be constructed. TESTS:: sage: G.<a,b> = FreeGroup() # indirect doctest sage: G Free Group on generators {a, b} sage: G.variable_names() ('a', 'b') """ n = len(generator_names) self._assign_names(generator_names) if libgap_free_group is None: libgap_free_group = libgap.FreeGroup(generator_names) ParentLibGAP.__init__(self, libgap_free_group) Group.__init__(self)
def __init__(self, degree, base_ring, libgap_group, ambient=None, category=None): """ Base class for matrix groups that implements GAP interface. INPUT: - ``degree`` -- integer. The degree (matrix size) of the matrix group. - ``base_ring`` -- ring. The base ring of the matrices. - ``libgap_group`` -- the defining libgap group. - ``ambient`` -- A derived class of :class:`ParentLibGAP` or ``None`` (default). The ambient class if ``libgap_group`` has been defined as a subgroup. TESTS:: sage: from sage.groups.matrix_gps.matrix_group import MatrixGroup_gap sage: MatrixGroup_gap(2, ZZ, libgap.eval('GL(2, Integers)')) Matrix group over Integer Ring with 3 generators ( [0 1] [-1 0] [1 1] [1 0], [ 0 1], [0 1] ) """ ParentLibGAP.__init__(self, libgap_group, ambient=ambient) MatrixGroup_generic.__init__(self, degree, base_ring, category=category)
def __init__(self, free_group, relations): """ The Python constructor TESTS:: sage: G = FreeGroup('a, b') sage: H = G / (G([1]), G([2])^3) sage: H Finitely presented group < a, b | a, b^3 > sage: F = FreeGroup('a, b') sage: J = F / (F([1]), F([2, 2, 2])) sage: J is H True sage: TestSuite(H).run() sage: TestSuite(J).run() """ from sage.groups.free_group import is_FreeGroup assert is_FreeGroup(free_group) assert isinstance(relations, tuple) self._free_group = free_group self._relations = relations self._assign_names(free_group.variable_names()) parent_gap = free_group.gap() / libgap([ rel.gap() for rel in relations]) ParentLibGAP.__init__(self, parent_gap) Group.__init__(self)
def __init__(self, free_group, relations): """ The Python constructor. TESTS:: sage: G = FreeGroup('a, b') sage: H = G / (G([1]), G([2])^3) sage: H Finitely presented group < a, b | a, b^3 > sage: F = FreeGroup('a, b') sage: J = F / (F([1]), F([2, 2, 2])) sage: J is H True sage: TestSuite(H).run() sage: TestSuite(J).run() """ from sage.groups.free_group import is_FreeGroup assert is_FreeGroup(free_group) assert isinstance(relations, tuple) self._free_group = free_group self._relations = relations self._assign_names(free_group.variable_names()) parent_gap = free_group.gap() / libgap( [rel.gap() for rel in relations]) ParentLibGAP.__init__(self, parent_gap) Group.__init__(self)
def __init__(self, G, category, ambient=None): r""" Create an instance of this class. See :class:`AbelianGroup_gap` for details TESTS:: sage: from sage.groups.abelian_gps.abelian_group_gap import AbelianGroupGap sage: G = AbelianGroupGap([3,2,5]) sage: TestSuite(G).run() """ AbelianGroupBase.__init__(self, category=category) ParentLibGAP.__init__(self, G, ambient=ambient)
def __init__(self, domain, gap_group, category, ambient=None): """ Constructor. EXAMPLES:: sage: from sage.groups.abelian_gps.abelian_group_gap import AbelianGroupGap sage: G = AbelianGroupGap([2,3,4,5]) sage: G.aut() Full group of automorphisms of Abelian group with gap, generator orders (2, 3, 4, 5) """ self._domain = domain n = len(self._domain.gens()) self._covering_matrix_ring = MatrixSpace(ZZ, n) ParentLibGAP.__init__(self, gap_group, ambient=ambient) Group.__init__(self, category=category)
def __init__(self, *args, **kwds): """ Group interface for LibGAP-based groups. INPUT: Same as :class:`~sage.groups.libgap_wrapper.ParentLibGAP`. TESTS:: sage: F.<a,b> = FreeGroup() sage: G_gap = libgap.Group([ (a*b^2).gap() ]) sage: from sage.groups.libgap_group import GroupLibGAP sage: G = GroupLibGAP(G_gap); G Group([ a*b^2 ]) sage: g = G.gen(0); g a*b^2 sage: TestSuite(G).run(skip=['_test_pickling', '_test_elements']) sage: TestSuite(g).run(skip=['_test_pickling']) """ ParentLibGAP.__init__(self, *args, **kwds) Group.__init__(self)
def __init__(self, degree, base_ring, libgap_group, ambient=None, category=None): """ Base class for matrix groups that implements GAP interface. INPUT: - ``degree`` -- integer. The degree (matrix size) of the matrix group. - ``base_ring`` -- ring. The base ring of the matrices. - ``libgap_group`` -- the defining libgap group. - ``ambient`` -- A derived class of :class:`ParentLibGAP` or ``None`` (default). The ambient class if ``libgap_group`` has been defined as a subgroup. TESTS: :: sage: from sage.groups.matrix_gps.matrix_group import MatrixGroup_gap sage: MatrixGroup_gap(2, ZZ, libgap.eval('GL(2, Integers)')) Matrix group over Integer Ring with 3 generators ( [0 1] [-1 0] [1 1] [1 0], [ 0 1], [0 1] ) Check that the slowness of GAP iterators and enumerators for matrix groups (cf. http://tracker.gap-system.org/issues/369) has been fixed:: sage: i = iter(GL(6,5)) sage: [ next(i) for j in range(8) ] [ [1 0 0 0 0 0] [4 0 0 0 0 1] [0 4 0 0 0 0] [0 4 0 0 0 0] [0 1 0 0 0 0] [4 0 0 0 0 0] [0 0 4 0 0 0] [0 0 4 0 0 0] [0 0 1 0 0 0] [0 4 0 0 0 0] [0 0 0 4 0 0] [0 0 0 4 0 0] [0 0 0 1 0 0] [0 0 4 0 0 0] [0 0 0 0 4 0] [0 0 0 0 4 0] [0 0 0 0 1 0] [0 0 0 4 0 0] [0 0 0 0 0 4] [0 0 0 0 0 4] [0 0 0 0 0 1], [0 0 0 0 4 0], [1 4 0 0 0 0], [2 4 0 0 0 0], [3 0 0 0 0 1] [4 0 0 1 3 3] [0 0 0 2 0 0] [1 0 0 0 4 4] [3 0 0 0 0 0] [4 0 0 0 3 3] [0 0 0 0 4 0] [1 0 0 0 0 4] [0 4 0 0 0 0] [3 0 0 0 0 1] [2 2 0 0 0 2] [1 0 0 0 0 0] [0 0 4 0 0 0] [3 0 0 0 0 0] [1 4 0 0 0 0] [0 1 0 0 0 0] [0 0 0 4 0 0] [0 4 0 0 0 0] [0 2 4 0 0 0] [0 0 1 0 0 0] [4 0 0 0 2 3], [2 0 3 4 4 4], [0 0 1 4 0 0], [0 0 0 1 0 0] ] And the same for listing the group elements, as well as few other issues:: sage: F = GF(3) sage: gens = [matrix(F,2, [1,0, -1,1]), matrix(F, 2, [1,1,0,1])] sage: G = MatrixGroup(gens) sage: G.cardinality() 24 sage: v = G.list() sage: len(v) 24 sage: v[:5] ( [0 1] [0 1] [0 1] [0 2] [0 2] [2 0], [2 1], [2 2], [1 0], [1 1] ) sage: all(g in G for g in G.list()) True An example over a ring (see :trac:`5241`):: sage: M1 = matrix(ZZ,2,[[-1,0],[0,1]]) sage: M2 = matrix(ZZ,2,[[1,0],[0,-1]]) sage: M3 = matrix(ZZ,2,[[-1,0],[0,-1]]) sage: MG = MatrixGroup([M1, M2, M3]) sage: MG.list() ( [-1 0] [-1 0] [ 1 0] [1 0] [ 0 -1], [ 0 1], [ 0 -1], [0 1] ) sage: MG.list()[1] [-1 0] [ 0 1] sage: MG.list()[1].parent() Matrix group over Integer Ring with 3 generators ( [-1 0] [ 1 0] [-1 0] [ 0 1], [ 0 -1], [ 0 -1] ) An example over a field (see :trac:`10515`):: sage: gens = [matrix(QQ,2,[1,0,0,1])] sage: MatrixGroup(gens).list() ( [1 0] [0 1] ) Another example over a ring (see :trac:`9437`):: sage: len(SL(2, Zmod(4)).list()) 48 An error is raised if the group is not finite:: sage: GL(2,ZZ).list() Traceback (most recent call last): ... NotImplementedError: group must be finite """ ParentLibGAP.__init__(self, libgap_group, ambient=ambient) MatrixGroup_generic.__init__(self, degree, base_ring, category=category)