---
title: "Creation of a Matrix Group"
canonical: "https://docs.magma-maths.org/v2.30-1/FiniteGroups/MatrixGroupsOverGeneralRings/creation-general-linear-group.html"
source: "https://docs.magma-maths.org/v2.30-1/FiniteGroups/MatrixGroupsOverGeneralRings/creation-general-linear-group.md"
part: "Finite Groups"
chapter: "Matrix Groups over General Rings"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Finite Groups", "source": "https://docs.magma-maths.org/v2.30-1/FiniteGroups/index-finite-groups.md"}
  - {"title": "Matrix Groups over General Rings", "source": "https://docs.magma-maths.org/v2.30-1/FiniteGroups/MatrixGroupsOverGeneralRings/index-matrix-groups-over-general-rings.md"}
prev: {"title": "Introduction", "source": "https://docs.magma-maths.org/v2.30-1/FiniteGroups/MatrixGroupsOverGeneralRings/introduction.md"}
next: {"title": "Homomorphisms", "source": "https://docs.magma-maths.org/v2.30-1/FiniteGroups/MatrixGroupsOverGeneralRings/homomorphism.md"}
intrinsics:
  - {"name": "GeneralLinearGroup", "signature": "GeneralLinearGroup(n, R): RngIntElt, Rng -> GrpMat"}
  - {"name": "GL", "signature": "GL(n, R): RngIntElt, Rng -> GrpMat"}
  - {"name": "elt", "signature": "elt< G | L >: GrpMat, List(RngElt) -> GrpMatElt"}
  - {"name": "!", "signature": "G ! Q: GrpMat, [ RngElt ] -> GrpMatElt"}
  - {"name": "ElementToSequence", "signature": "ElementToSequence(g): GrpMatElt -> [ RngElt ]"}
  - {"name": "Eltseq", "signature": "Eltseq(g): GrpMatElt -> [ RngElt ]"}
  - {"name": "Identity", "signature": "Identity(G): GrpMat -> GrpMatElt"}
  - {"name": "Id", "signature": "Id(G): GrpMat -> GrpMatElt"}
  - {"name": "!", "signature": "G ! 1: GrpMat, RngIntElt -> GrpMatElt"}
  - {"name": "MatrixGroup", "signature": "MatrixGroup< n, R | L >: RngIntElt, Rng, List -> GrpMat"}
  - {"name": "ChangeRing", "signature": "ChangeRing(G, S): GrpMat, Rng -> GrpMat, Map"}
  - {"name": "ChangeRing", "signature": "ChangeRing(G, S, f): GrpMat, Rng, Map -> GrpMat, Map"}
  - {"name": "RestrictField", "signature": "RestrictField(G, S): GrpMat, FldFin -> GrpMat, Map"}
  - {"name": "ExtendField", "signature": "ExtendField(G, L): GrpMat, FldFin -> GrpMat, Map"}
  - {"name": "!", "signature": "R ! g: AlgMat, GrpMatElt -> RngMatElt"}
  - {"name": "!", "signature": "G ! r: GrpMat, AlgMatElt -> GrpMatElt"}
  - {"name": "!", "signature": "M ! g: ModMatRng, GrpMatElt -> ModMatRngElt"}
  - {"name": "!", "signature": "G ! m: GrpMat, ModMatRngElt -> GrpMatElt"}
  - {"name": "ProjectionLocalization", "signature": "ProjectionLocalization(g, pi): GrpMatElt, Map -> GrpMatElt"}
  - {"name": ".", "signature": "G . i: GrpMat, RngIntElt -> GrpMatElt"}
  - {"name": "Degree", "signature": "Degree(G): GrpMat -> RngIntElt"}
  - {"name": "Generators", "signature": "Generators(G): GrpMat -> { GrpMatElt }"}
  - {"name": "NumberOfGenerators", "signature": "NumberOfGenerators(G): GrpMat -> RngIntElt"}
  - {"name": "Ngens", "signature": "Ngens(G): GrpMat -> RngIntElt"}
  - {"name": "CoefficientRing", "signature": "CoefficientRing(G): GrpMat -> Rng"}
  - {"name": "BaseRing", "signature": "BaseRing(G): GrpMat -> Rng"}
  - {"name": "RSpace", "signature": "RSpace(G): GrpMat -> ModTupRng"}
  - {"name": "VectorSpace", "signature": "VectorSpace(G): GrpMat -> ModTupFld"}
  - {"name": "GModule", "signature": "GModule(G): GrpMat -> ModGrp"}
  - {"name": "Generic", "signature": "Generic(G): GrpMat -> GrpMat"}
  - {"name": "Parent", "signature": "Parent(G): GrpMatElt -> GrpMat"}
examples:
  - "ex-59ac81"
  - "ex-da01c4"
  - "ex-383e20"
  - "ex-0a504f"
---

# Creation of a Matrix Group

## Construction of the General Linear Group

<a id="function-generallineargroup-rngintelt-rng"></a>
### `GeneralLinearGroup(n, R): RngIntElt, Rng -> GrpMat`

<a id="function-gl-rngintelt-rng"></a>
### `GL(n, R): RngIntElt, Rng -> GrpMat`

Given an integer $n \geq 1$ and a ring $R$, create the generic matrix group, i.e. the general linear group ${\operatorname{GL}}(n, R)$. Initially, only a structure table is created for ${\operatorname{GL}}(n, R)$, so that, in particular, generators are not defined. This function is normally used to provide a context for the creation of elements and subgroups of ${\operatorname{GL}}(n, R)$. If structural computation is attempted with the group created by `GeneralLinearGroup(n, R)`, then generators will be created where possible. At present, this is only permitted in the cases in which $R$ is a finite field.

<a id="example-ex-59ac81"></a>
### `Example: Constructing GL(3, 4) (ex-59ac81)`

We define the general linear group ${\operatorname{GL}}(3, K)$, where $K$ is the finite field ${\bf F}_{4}$.

```magma
> K<w> := FiniteField(4);
> GL34 := GeneralLinearGroup(3, K);
> GL34;
GL(3, GF(2, 2))
```

## Construction of a Matrix Group Element

Throughout this subsection we shall assume that the matrix group $G$ is defined over the ring $R$.

<a id="constructor-constructor-elt-grpmat-list-rngelt-grpmatelt"></a>
### `elt< G | L >: GrpMat, List(RngElt) -> GrpMatElt`

Given a matrix group $G$ defined as a subgroup of ${\operatorname{GL}}(n, R)$, and the list $L$ of expressions $a_{ij}$ ($1 \leq i, j \leq n$), defining elements of the ring $R$, construct the $n\times n$ matrix

$$
\begin{pmatrix}a_{11}&a_{12}&\ldots&a_{1n}\\ a_{21}&a_{22}&\ldots&a_{2n}\\ \vdots&\vdots&\ddots&\vdots\\ a_{n1}&a_{n2}&\ldots&a_{nn}\end{pmatrix}
$$

Unless $G$ is known to be the generic matrix group of degree $n$, the matrix will be tested for membership of $G$, and if $g$ is not an element of $G$, the function will fail. If $g$ does lie in $G$, $g$ will have $G$ as its parent. Since the membership test may involve constructing a base and strong generating set for $G$, this constructor may occasionally be very costly. Hence a matrix $g$ should be defined as an element of a subgroup of the generic group only when membership of $G$ is required by subsequent operations involving $g$.

<a id="operation-op-grpmat-rngelt"></a>
### `G ! Q: GrpMat, [ RngElt ] -> GrpMatElt`

Given the sequence $Q$ of expressions $a_{ij}$ ($1 \leq i, j \leq n$), defining elements of the ring $R$, construct the $n\times n$ matrix

$$
\begin{pmatrix}a_{11}&a_{12}&\ldots&a_{1n}\\ a_{21}&a_{22}&\ldots&a_{2n}\\ \vdots&\vdots&\ddots&\vdots\\ a_{n1}&a_{n2}&\ldots&a_{nn}\end{pmatrix}
$$

This matrix will have $G$ as its parent structure. As in the case of the `elt`-constructor, the operation will fail if $g$ is not an element of $G$, and the same observations concerning the cost of membership testing apply.

<a id="function-elementtosequence-grpmatelt"></a>
### `ElementToSequence(g): GrpMatElt -> [ RngElt ]`

<a id="function-eltseq-grpmatelt"></a>
### `Eltseq(g): GrpMatElt -> [ RngElt ]`

Given an $n \times n$ matrix $g = (a_{ij}), 1 \le i, j \le n$, where $a_{ij}$ is an element of the ring $R$, construct the sequence

$$
[ a_{11}, \ldots, a_{1n}, a_{21}, \ldots, a_{2n}, \ldots a_{n1}, \ldots, a_{nn}]
$$

of $n^2$ elements of the ring $R$.

<a id="function-identity-grpmat"></a>
### `Identity(G): GrpMat -> GrpMatElt`

<a id="function-id-grpmat"></a>
### `Id(G): GrpMat -> GrpMatElt`

<a id="operation-op-grpmat-rngintelt"></a>
### `G ! 1: GrpMat, RngIntElt -> GrpMatElt`

Construct the identity matrix in the matrix group $G$.

<a id="example-ex-da01c4"></a>
### `Example: Elements of GL(3, 4) (ex-da01c4)`

The different constructions are illustrated by the following code, which assigns to each of the variables $x$ and $y$ an element of ${\operatorname{GL}}(3, 4)$.

```magma
> K<w> := FiniteField(4);
> GL34 := GeneralLinearGroup(3, K);
> x := elt<GL34 | w,0,1, 0,1,0, 1,0,1 >;
> x;
[w 0 1]
[0 1 0]
[1 0 1]
> y := GL34 ! [w,0,1, 0,1,0, 1,0,1];
> y;
[w 0 1]
[0 1 0]
[1 0 1]
> GL34 ! 1;
[1 0 0]
[0 1 0]
[0 0 1]
```

## Construction of a General Matrix Group

<a id="constructor-constructor-matrixgroup-rngintelt-rng-list-grpmat"></a>
### `MatrixGroup< n, R | L >: RngIntElt, Rng, List -> GrpMat`

Construct the matrix group $G$ of degree $n$ over the ring $R$ generated by the matrices defined by the list $L$. A term of the list $L$ must be an object of one of the following types:

**(a)**
A sequence of $n^2$ elements of $R$ defining a matrix of ${\operatorname{GL}}(n, R)$;

**(b)**
A set or sequence of sequences of type (a);

**(c)**
An element of ${\operatorname{GL}}(n, R)$;

**(d)**
A set or sequence of elements of ${\operatorname{GL}}(n, R)$;

**(e)**
A subgroup of ${\operatorname{GL}}(n, R)$;

**(f)**
A set or sequence of subgroups of ${\operatorname{GL}}(n, R)$.

Each element or group specified by the list must belong to the *same* generic matrix group. The group $G$ will be constructed as a subgroup of some group which contains each of the elements and groups specified in the list. The generators of $G$ consist of the elements specified by the terms of the list $L$ together with the stored generators for groups specified by terms of the list. Repetitions of an element and occurrences of the identity element are removed.

The `MatrixGroup` constructor is shorthand for the two statements:

```
   GL := GeneralLinearGroup(n, R);

   G := sub< GL | L >;
```

where `sub< ... >` is the subgroup constructor described in the next subsection.

<a id="example-ex-383e20"></a>
### `Example: Subgroup of GL(3, 4) by Generators (ex-383e20)`

We use the `MatrixGroup` constructor to define a small subgroup of ${\operatorname{GL}}(3, 4)$.

```magma
> K<w> := FiniteField(4);
> H := MatrixGroup< 3, K | [1,w,0, 0,1,0, 1,w^2,1], [w,0,0, 0,1,0, 0,0,w] >;
> H;
MatrixGroup(3, GF(2, 2))
Generators:
[  1   w   0]
[  0   1   0]
[  1 w^2   1]

[w 0 0]
[0 1 0]
[0 0 w]
> Order(H);
96
```

<a id="example-ex-0a504f"></a>
### `Example: Sylow Subgroup of a General Linear Group (ex-0a504f)`

We present a function which will construct the Sylow $p$-subgroup of ${\operatorname{GL}}(n, K)$, where $K$ is a finite field of characteristic $p$.

```magma
> GLSyl := function(n, K)
>    R := MatrixRing(K, n);
>    e := func< i, j | MatrixUnit(R, i, j) >;
>    return MatrixGroup< n, K | { R!1 + a*e(i,j) : a in K, j in [i+1],
>          i in [1 .. n - 1] | a ne 0 } >;
> end function;
> T := GLSyl(3, GF(8));
> FactoredOrder(T);
[ <2, 9> ]
> FactoredOrder(GL(3, GF(8)));
[ <2, 9>, <3, 2>, <7, 3>, <73, 1> ]
```

## Changing Rings

<a id="function-changering-grpmat-rng"></a>
### `ChangeRing(G, S): GrpMat, Rng -> GrpMat, Map`

Given a matrix group $G$ with base ring $R$, construct a new matrix group $H$ with base ring $S$ derived from $G$ by coercing entries of the generators of $G$ from $R$ into $S$.

<a id="function-changering-grpmat-rng-map"></a>
### `ChangeRing(G, S, f): GrpMat, Rng, Map -> GrpMat, Map`

Given a matrix group $G$ with base ring $R$, construct a new matrix group $H$ with base ring $S$ derived from $G$ by applying $f$ to the entries of the generators of $G$.

<a id="function-restrictfield-grpmat-fldfin"></a>
### `RestrictField(G, S): GrpMat, FldFin -> GrpMat, Map`

Given a matrix group $G$ with base ring $K$, a finite field, and $S$ a subfield of $K$, construct the matrix group $H$ with base ring $S$ obtained by restricting the scalars of the components of elements of $G$ into $S$, together with the restriction map from $G$ onto $H$.

<a id="function-extendfield-grpmat-fldfin"></a>
### `ExtendField(G, L): GrpMat, FldFin -> GrpMat, Map`

Given a matrix group $G$ with base ring $K$, a finite field, and $L$ an extension of $K$, construct the matrix group $H$ with base ring $L$ obtained by lifting the components of elements of $G$ into $L$, together with the inclusion homomorphism from $G$ into $H$.

## Coercion between Matrix Structures

A square non-singular matrix may be defined as an element of any of the following structures:

- A subring of the complete matrix ring $M_{n}(R)$;
- A subgroup of the general linear group ${\operatorname{GL}}(n, R)$;
- A submodule of the matrix module $M^{(m \times n)}(R)$.

The coercion operator may be used to transfer matrices between any two of these three structures.

<a id="operation-op-algmat-grpmatelt"></a>
### `R ! g: AlgMat, GrpMatElt -> RngMatElt`

Transfer the matrix $g$ from a group into a matrix ring $R$.

<a id="operation-op-grpmat-algmatelt"></a>
### `G ! r: GrpMat, AlgMatElt -> GrpMatElt`

Transfer the matrix $r$ from a ring into a matrix group $G$.

<a id="operation-op-modmatrng-grpmatelt"></a>
### `M ! g: ModMatRng, GrpMatElt -> ModMatRngElt`

Transfer the matrix $g$ from a group into a matrix module $M$.

<a id="operation-op-grpmat-modmatrngelt"></a>
### `G ! m: GrpMat, ModMatRngElt -> GrpMatElt`

Transfer the matrix $m$ from a module into a matrix group $G$.

<a id="function-projectionlocalization-grpmatelt-map"></a>
### `ProjectionLocalization(g, pi): GrpMatElt, Map -> GrpMatElt`

For a square matrix $g$ with elements inside a localization $R_{(p)}$ of a ring $R$ (so all denominators are prime to $p$), given a projection map $\pi : R \to R/p$, returns the image of $g$ under the map induced by $\pi$.

## Accessing Associated Structures

The functions in this group provide access to basic information stored for a matrix group $G$.

<a id="operation-operation-grpmat-rngintelt-grpmatelt"></a>
### `G . i: GrpMat, RngIntElt -> GrpMatElt`

The $i$-th defining generator for the matrix group $G$. A negative subscript indicates that the inverse of the generator is to be created. The $0$th generator `G.0` is `Identity(G)`.

<a id="function-degree-grpmat"></a>
### `Degree(G): GrpMat -> RngIntElt`

The degree of the matrix group $G$.

<a id="function-generators-grpmat"></a>
### `Generators(G): GrpMat -> { GrpMatElt }`

A set containing the defining generators for the matrix group $G$.

<a id="function-numberofgenerators-grpmat"></a>
### `NumberOfGenerators(G): GrpMat -> RngIntElt`

<a id="function-ngens-grpmat"></a>
### `Ngens(G): GrpMat -> RngIntElt`

The number of defining generators for the matrix group $G$.

<a id="function-coefficientring-grpmat"></a>
### `CoefficientRing(G): GrpMat -> Rng`

<a id="function-basering-grpmat"></a>
### `BaseRing(G): GrpMat -> Rng`

The coefficient ring for the matrix group $G$.

<a id="function-rspace-grpmat"></a>
### `RSpace(G): GrpMat -> ModTupRng`

Given a matrix group $G$ of degree $n$ defined over a ring $R$, return the space $R^{(n)}$, where the action is multiplication by elements of $R$, i.e. scalar action.

<a id="function-vectorspace-grpmat"></a>
### `VectorSpace(G): GrpMat -> ModTupFld`

Given a matrix group $G$ of degree $n$ defined over a field $K$, return the space $K^{(n)}$, where the action is multiplication by elements of $K$, i.e. scalar action.

<a id="function-gmodule-grpmat"></a>
### `GModule(G): GrpMat -> ModGrp`

The natural $R[G]$-module for the matrix group $G$.

<a id="function-generic-grpmat"></a>
### `Generic(G): GrpMat -> GrpMat`

The generic group containing the matrix group $G$, i.e. the general linear group in which $G$ is naturally embedded.

<a id="function-parent-grpmatelt"></a>
### `Parent(G): GrpMatElt -> GrpMat`

The power structure for the group $G$ (the set consisting of all matrix groups).
