# Creation of a Matrix Group

## Construction of the General Linear Group

### `GeneralLinearGroup(n, R): RngIntElt, Rng -> GrpMat`

### `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.

### `Example: Create (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$.

### `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$.

### `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.

### `ElementToSequence(g): GrpMatElt -> [ RngElt ]`

### `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$.

### `Identity(G): GrpMat -> GrpMatElt`

### `Id(G): GrpMat -> GrpMatElt`

### `G ! 1: GrpMat, RngIntElt -> GrpMatElt`

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

### `Example: Matrices (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

### `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.

### `Example: Constructor (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

```

### `Example: GL Sylow (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

### `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$.

### `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$.

### `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$.

### `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.

### `R ! g: AlgMat, GrpMatElt -> RngMatElt`

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

### `G ! r: GrpMat, AlgMatElt -> GrpMatElt`

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

### `M ! g: ModMatRng, GrpMatElt -> ModMatRngElt`

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

### `G ! m: GrpMat, ModMatRngElt -> GrpMatElt`

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

### `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$.

### `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)`.

### `Degree(G): GrpMat -> RngIntElt`

The degree of the matrix group $G$.

### `Generators(G): GrpMat -> { GrpMatElt }`

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

### `NumberOfGenerators(G): GrpMat -> RngIntElt`

### `Ngens(G): GrpMat -> RngIntElt`

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

### `CoefficientRing(G): GrpMat -> Rng`

### `BaseRing(G): GrpMat -> Rng`

The coefficient ring for the matrix group $G$.

### `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.

### `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.

### `GModule(G): GrpMat -> ModGrp`

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

### `Generic(G): GrpMat -> GrpMat`

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

### `Parent(G): GrpMatElt -> GrpMat`

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