Base classes for Matrix Groups#

Loading, saving, … works:

sage: G = GL(2,5); G
General Linear Group of degree 2 over Finite Field of size 5
sage: TestSuite(G).run()

sage: g = G.1; g
[4 1]
[4 0]
sage: TestSuite(g).run()

We test that trac ticket #9437 is fixed:

sage: len(list(SL(2, Zmod(4))))


  • William Stein: initial version

  • David Joyner (2006-03-15): degree, base_ring, _contains_, list, random, order methods; examples

  • William Stein (2006-12): rewrite

  • David Joyner (2007-12): Added invariant_generators (with Martin Albrecht and Simon King)

  • David Joyner (2008-08): Added module_composition_factors (interface to GAP’s MeatAxe implementation) and as_permutation_group (returns isomorphic PermutationGroup).

  • Simon King (2010-05): Improve invariant_generators by using GAP for the construction of the Reynolds operator in Singular.

  • Sebastian Oehms (2018-07): Add subgroup() and ambient() see trac ticket #25894

class sage.groups.matrix_gps.matrix_group.MatrixGroup_base#


Base class for all matrix groups.

This base class just holds the base ring, but not the degree. So it can be a base for affine groups where the natural matrix is larger than the degree of the affine group. Makes no assumption about the group except that its elements have a matrix() method.


Return the ambient group of a subgroup.


A group containing self. If self has not been defined as a subgroup, we just return self.


sage: G = GL(2,QQ)
sage: m = matrix(QQ, 2,2, [[3, 0],[~5,1]])
sage: S = G.subgroup([m])
sage: S.ambient() is G

Return a new matrix group from the generators.

This will throw away any extra structure (encoded in a derived class) that a group of special matrices has.


sage: G = SU(4,GF(5))
sage: G.as_matrix_group()
Matrix group over Finite Field in a of size 5^2 with 2 generators (
[      a       0       0       0]  [      1       0 4*a + 3       0]
[      0 2*a + 3       0       0]  [      1       0       0       0]
[      0       0 4*a + 1       0]  [      0 2*a + 4       0       1]
[      0       0       0     3*a], [      0 3*a + 1       0       0]

sage: G = GO(3,GF(5))
sage: G.as_matrix_group()
Matrix group over Finite Field of size 5 with 2 generators (
[2 0 0]  [0 1 0]
[0 3 0]  [1 4 4]
[0 0 1], [0 2 1]
sign_representation(base_ring=None, side='twosided')#

Return the sign representation of self over base_ring.

WARNING: assumes self is a matrix group over a field which has embedding over real numbers.


  • base_ring – (optional) the base ring; the default is \(\ZZ\)

  • side – ignored


sage: G = GL(2, QQ)
sage: V = G.sign_representation()
sage: e = G.an_element()
sage: e
[1 0]
[0 1]
sage: V._default_sign(e)
sage: m2 = V.an_element()
sage: m2
sage: m2*e
sage: m2*e*e
subgroup(generators, check=True)#

Return the subgroup generated by the given generators.


  • generators – a list/tuple/iterable of group elements of self

  • check – boolean (optional, default: True). Whether to check that each matrix is invertible.

OUTPUT: The subgroup generated by generators as an instance of FinitelyGeneratedMatrixGroup_gap


sage: UCF = UniversalCyclotomicField()
sage: G  = GL(3, UCF)
sage: e3 = UCF.gen(3); e5 =UCF.gen(5)
sage: m = matrix(UCF, 3,3, [[e3, 1, 0], [0, e5, 7],[4, 3, 2]])
sage: S = G.subgroup([m]); S
Subgroup with 1 generators (
[E(3)    1    0]
[   0 E(5)    7]
[   4    3    2]
) of General Linear Group of degree 3 over Universal Cyclotomic Field

sage: CF3 = CyclotomicField(3)
sage: G  = GL(3, CF3)
sage: e3 = CF3.gen()
sage: m = matrix(CF3, 3,3, [[e3, 1, 0], [0, ~e3, 7],[4, 3, 2]])
sage: S = G.subgroup([m]); S
Subgroup with 1 generators (
[     zeta3          1          0]
[         0 -zeta3 - 1          7]
[         4          3          2]
) of General Linear Group of degree 3 over Cyclotomic Field of order 3 and degree 2
class sage.groups.matrix_gps.matrix_group.MatrixGroup_gap(degree, base_ring, libgap_group, ambient=None, category=None)#

Bases: sage.groups.libgap_mixin.GroupMixinLibGAP, sage.groups.matrix_gps.matrix_group.MatrixGroup_generic, sage.groups.libgap_wrapper.ParentLibGAP

Base class for matrix groups that implements GAP interface.


  • 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 ParentLibGAP or None (default). The ambient class if libgap_group has been defined as a subgroup.


alias of sage.groups.matrix_gps.group_element.MatrixGroupElement_gap

structure_description(G, latex=False)#

Return a string that tries to describe the structure of G.

This methods wraps GAP’s StructureDescription method.

For full details, including the form of the returned string and the algorithm to build it, see GAP’s documentation.


  • latex – a boolean (default: False). If True return a LaTeX formatted string.


  • string


From GAP’s documentation: The string returned by StructureDescription is not an isomorphism invariant: non-isomorphic groups can have the same string value, and two isomorphic groups in different representations can produce different strings.


sage: G = CyclicPermutationGroup(6)
sage: G.structure_description()
sage: G.structure_description(latex=True)
sage: G2 = G.direct_product(G, maps=False)
sage: LatexExpr(G2.structure_description(latex=True))
C_{6} \times C_{6}

This method is mainly intended for small groups or groups with few normal subgroups. Even then there are some surprises:

sage: D3 = DihedralGroup(3)
sage: D3.structure_description()

We use the Sage notation for the degree of dihedral groups:

sage: D4 = DihedralGroup(4)
sage: D4.structure_description()

Works for finitely presented groups (trac ticket #17573):

sage: F.<x, y> = FreeGroup()
sage: G = F / [x^2*y^-1, x^3*y^2, x*y*x^-1*y^-1]
sage: G.structure_description()

And matrix groups (trac ticket #17573):

sage: groups.matrix.GL(4,2).structure_description()
class sage.groups.matrix_gps.matrix_group.MatrixGroup_generic(degree, base_ring, category=None)#

Bases: sage.groups.matrix_gps.matrix_group.MatrixGroup_base

Base class for matrix groups over generic base rings

You should not use this class directly. Instead, use one of the more specialized derived classes.


  • degree – integer. The degree (matrix size) of the matrix group.

  • base_ring – ring. The base ring of the matrices.


alias of sage.groups.matrix_gps.group_element.MatrixGroupElement_generic


Return the degree of this matrix group.


Integer. The size (number of rows equals number of columns) of the matrices.


sage: SU(5,5).degree()

Return the matrix space corresponding to this matrix group.

This is a matrix space over the field of definition of this matrix group.


sage: F = GF(5); MS = MatrixSpace(F,2,2)
sage: G = MatrixGroup([MS(1), MS([1,2,3,4])])
sage: G.matrix_space()
Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 5
sage: G.matrix_space() is MS

Test whether x is a matrix group.


sage: from sage.groups.matrix_gps.matrix_group import is_MatrixGroup
sage: is_MatrixGroup(MatrixSpace(QQ,3))
sage: is_MatrixGroup(Mat(QQ,3))
sage: is_MatrixGroup(GL(2,ZZ))
sage: is_MatrixGroup(MatrixGroup([matrix(2,[1,1,0,1])]))