# Base classes for Matrix Groups#

AUTHORS:

• 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 Issue #25894

class sage.groups.matrix_gps.matrix_group.MatrixGroup_base[source]#

Bases: `Group`

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.

ambient()[source]#

Return the ambient group of a subgroup.

OUTPUT:

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

EXAMPLES:

```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
True
```
```>>> from sage.all import *
>>> G = GL(Integer(2), QQ)
>>> m = matrix(QQ, Integer(2), Integer(2), [[Integer(3), Integer(0)], [~Integer(5),Integer(1)]])
>>> S = G.subgroup([m])
>>> S.ambient() is G
True
```
as_matrix_group()[source]#

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.

EXAMPLES:

```sage: G = SU(4, GF(5))                                                      # needs sage.rings.finite_rings
sage: G.as_matrix_group()                                                   # needs sage.libs.gap sage.rings.finite_rings
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: # needs sage.libs.gap
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]
)
```
```>>> from sage.all import *
>>> G = SU(Integer(4), GF(Integer(5)))                                                      # needs sage.rings.finite_rings
>>> G.as_matrix_group()                                                   # needs sage.libs.gap sage.rings.finite_rings
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]
)

>>> # needs sage.libs.gap
>>> G = GO(Integer(3), GF(Integer(5)))
>>> 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]
)
```
natural_representation(base_ring=None)[source]#

Return the natural representation of `self` over `base_ring`.

INPUT:

• `base_ring` – (optional) the base ring; the default is the base ring of `self`

EXAMPLES:

```sage: G = groups.matrix.SL(6, 3)
sage: V = G.natural_representation()
sage: V
Natural representation of Special Linear Group of degree 6
over Finite Field of size 3
sage: e = prod(G.gens())
sage: e
[2 0 0 0 0 1]
[2 0 0 0 0 0]
[0 2 0 0 0 0]
[0 0 2 0 0 0]
[0 0 0 2 0 0]
[0 0 0 0 2 0]
sage: v = V.an_element()
sage: v
2*e[0] + 2*e[1]
sage: e * v
e[0] + e[1] + e[2]
```
```>>> from sage.all import *
>>> G = groups.matrix.SL(Integer(6), Integer(3))
>>> V = G.natural_representation()
>>> V
Natural representation of Special Linear Group of degree 6
over Finite Field of size 3
>>> e = prod(G.gens())
>>> e
[2 0 0 0 0 1]
[2 0 0 0 0 0]
[0 2 0 0 0 0]
[0 0 2 0 0 0]
[0 0 0 2 0 0]
[0 0 0 0 2 0]
>>> v = V.an_element()
>>> v
2*e[0] + 2*e[1]
>>> e * v
e[0] + e[1] + e[2]
```
sign_representation(base_ring=None)[source]#

Return the sign representation of `self` over `base_ring`.

INPUT:

• `base_ring` – (optional) the base ring; the default is the base ring of `self`

EXAMPLES:

```sage: G = GL(2, QQ)
sage: V = G.sign_representation()
sage: e = G.an_element()
sage: e
[1 0]
[0 1]
sage: m2 = V.an_element()
sage: m2
2*B['v']
sage: m2*e
2*B['v']
sage: m2*e*e
2*B['v']

sage: W = WeylGroup(["A", 1, 1])
sage: W.sign_representation()
Sign representation of
Weyl Group of type ['A', 1, 1] (as a matrix group acting on the root space)
over Rational Field

sage: G = GL(4, 2)
sage: G.sign_representation() == G.trivial_representation()
True
```
```>>> from sage.all import *
>>> G = GL(Integer(2), QQ)
>>> V = G.sign_representation()
>>> e = G.an_element()
>>> e
[1 0]
[0 1]
>>> m2 = V.an_element()
>>> m2
2*B['v']
>>> m2*e
2*B['v']
>>> m2*e*e
2*B['v']

>>> W = WeylGroup(["A", Integer(1), Integer(1)])
>>> W.sign_representation()
Sign representation of
Weyl Group of type ['A', 1, 1] (as a matrix group acting on the root space)
over Rational Field

>>> G = GL(Integer(4), Integer(2))
>>> G.sign_representation() == G.trivial_representation()
True
```
subgroup(generators, check=True)[source]#

Return the subgroup generated by the given generators.

INPUT:

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

• `check` – boolean (default: `True`); whether to check that each matrix is invertible

OUTPUT: the subgroup generated by `generators` as an instance of `FinitelyGeneratedMatrixGroup_gap`

EXAMPLES:

```sage: # needs sage.libs.gap sage.rings.number_field
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: # needs sage.rings.number_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
```
```>>> from sage.all import *
>>> # needs sage.libs.gap sage.rings.number_field
>>> UCF = UniversalCyclotomicField()
>>> G  = GL(Integer(3), UCF)
>>> e3 = UCF.gen(Integer(3)); e5 = UCF.gen(Integer(5))
>>> m = matrix(UCF, Integer(3),Integer(3), [[e3, Integer(1), Integer(0)], [Integer(0), e5, Integer(7)],[Integer(4), Integer(3), Integer(2)]])
>>> 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

>>> # needs sage.rings.number_field
>>> CF3 = CyclotomicField(Integer(3))
>>> G  = GL(Integer(3), CF3)
>>> e3 = CF3.gen()
>>> m = matrix(CF3, Integer(3),Integer(3), [[e3, Integer(1), Integer(0)], [Integer(0), ~e3, Integer(7)],[Integer(4), Integer(3), Integer(2)]])
>>> 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_generic(degree, base_ring, category=None)[source]#

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.

INPUT:

• `degree` – integer; the degree (matrix size) of the matrix group

• `base_ring` – ring; the base ring of the matrices

Element[source]#
degree()[source]#

Return the degree of this matrix group.

OUTPUT: integer; the size (number of rows equals number of columns) of the matrices

EXAMPLES:

```sage: SU(5,5).degree()                                                      # needs sage.rings.finite_rings
5
```
```>>> from sage.all import *
>>> SU(Integer(5),Integer(5)).degree()                                                      # needs sage.rings.finite_rings
5
```
is_trivial()[source]#

Return `True` if this group is the trivial group.

A group is trivial, if it consists only of the identity element, that is, if all its generators are the identity.

EXAMPLES:

```sage: MatrixGroup([identity_matrix(3)]).is_trivial()
True
sage: SL(2, ZZ).is_trivial()
False
sage: CoxeterGroup(['B',3], implementation="matrix").is_trivial()
False
```
```>>> from sage.all import *
>>> MatrixGroup([identity_matrix(Integer(3))]).is_trivial()
True
>>> SL(Integer(2), ZZ).is_trivial()
False
>>> CoxeterGroup(['B',Integer(3)], implementation="matrix").is_trivial()
False
```
matrix_space()[source]#

Return the matrix space corresponding to this matrix group.

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

EXAMPLES:

```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
True
```
```>>> from sage.all import *
>>> F = GF(Integer(5)); MS = MatrixSpace(F, Integer(2), Integer(2))
>>> G = MatrixGroup([MS(Integer(1)), MS([Integer(1),Integer(2),Integer(3),Integer(4)])])
>>> G.matrix_space()
Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 5
>>> G.matrix_space() is MS
True
```
sage.groups.matrix_gps.matrix_group.is_MatrixGroup(x)[source]#

Test whether `x` is a matrix group.

EXAMPLES:

```sage: from sage.groups.matrix_gps.matrix_group import is_MatrixGroup
sage: is_MatrixGroup(MatrixSpace(QQ, 3))
doctest:warning...
DeprecationWarning: the function is_MatrixGroup is deprecated;
See https://github.com/sagemath/sage/issues/37898 for details.
False
sage: is_MatrixGroup(Mat(QQ, 3))
False
sage: is_MatrixGroup(GL(2, ZZ))
True
sage: is_MatrixGroup(MatrixGroup([matrix(2, [1,1,0,1])]))
True
```
```>>> from sage.all import *
>>> from sage.groups.matrix_gps.matrix_group import is_MatrixGroup
>>> is_MatrixGroup(MatrixSpace(QQ, Integer(3)))
doctest:warning...
DeprecationWarning: the function is_MatrixGroup is deprecated;