# 41 Matrix Algebras

This chapter describes the data structures and functions for matrix algebras in GAP3. See chapter Algebras for the description of all those aspects that concern general algebras.

First the objects of interest in this chapter are introduced (see More about Matrix Algebras, Bases for Matrix Algebras).

The next sections describe functions for matrix algebras, first those that can be applied not only for matrix algebras (see IsMatAlgebra, Zero and One for Matrix Algebras, Functions for Matrix Algebras, Algebra Functions for Matrix Algebras, RepresentativeOperation for Matrix Algebras), and then specific matrix algebra functions (see MatAlgebra, NullAlgebra, Fingerprint, NaturalModule).

## 41.1 More about Matrix Algebras

A matrix algebra is an algebra (see More about Algebras) the elements of which are matrices.

There is a canonical isomorphism of a matrix algebra onto a row space (see chapter Row Spaces) that maps a matrix to the concatenation of its rows. This makes all computations with matrix algebras that use its vector space structure as efficient as the corresponding computation with a row space. For example the computation of a vector space basis, of coefficients with respect to such a basis, and of representatives under the action on a vector space by right multiplication.

If one is interested in matrix algebras as domains themselves then one should think of this algebra as of a row space that admits a multiplication. For example, the convention for row spaces that the coefficients field must contain the field of the vector elements also applies to matrix algebras. And the concept of vector space bases is the same as that for row spaces (see Bases for Matrix Algebras).

In the chapter about modules (see chapter Modules) it is stated that modules are of interest mainly as operation domains of algebras. Here we can state that matrix algebras are of interest mainly because they describe modules. For some of the functions it is not obvious whether they are functions for modules or for algebras or for the matrices that generate an algebra. For example, one usually talks about the fingerprint of an A-module M, but this is in fact computed as the list of nullspace dimensions of generators of a certain matrix algebra, namely the induced action of A on M as is computed using `Operation( A, M )` (see Fingerprint, Operation for Algebras).

## 41.2 Bases for Matrix Algebras

As stated in section More about Matrix Algebras, the implementation of bases for matrix algebras follows that of row space bases, see Row Space Bases for the details. Consequently there are two types of bases, arbitrary bases and semi-echelonized bases, where the latter type can be defined as follows. Let φ be the vector space homomorphism that maps a matrix in the algebra A to the concatenation of its rows, and let B = (b1, b2, ..., bn) be a vector space basis of A, then B is called semi-echelonized if and only if the row space basis (φ(b1), φ(b2), ..., φ(bn)) is semi-echelonized, in the sense of Row Space Bases. The canonical basis is defined analogeously.

Due to the multiplicative structure that allows to view a matrix algebra A as an A-module with action via multiplication from the right, there is additionally the notion of a standard basis for A, which is essentially described in StandardBasis for Row Modules. The default way to compute a vector space basis of a matrix algebra from a set of generating matrices is to compute this standard basis and a semi-echelonized basis in parallel.

If the matrix algebra A is unital then every semi-echelonized basis and also the standard basis have `One( A )` as first basis vector.

## 41.3 IsMatAlgebra

`IsMatAlgebra( obj )`

returns `true` if obj, which may be an object of arbitrary type, is a matrix algebra and `false` otherwise.

```    gap> IsMatAlgebra( FreeAlgebra( GF(2), 0 ) );
false
gap> IsMatAlgebra( Algebra( Rationals, [[[1]]] ) );
true ```

## 41.4 Zero and One for Matrix Algebras

`Zero( A )` :

returns the square zero matrix of the same dimension and characteristic as the elements of A. This matrix is thought only for testing whether a matrix is zero, usually all its rows will be identical in order to save space. So you should not use this zero matrix for other purposes; use NullMat `NullMat` instead.

`One( A )` :

returns for a unital matrix algebra A the identity matrix of the same dimension and characteristic as the elements of A; for a not unital matrix algebra A the (left and right) multiplicative neutral element (if exists) is computed by solving a linear equation system.

## 41.5 Functions for Matrix Algebras

`Closure`, `Elements`, `IsFinite`, and `Size` are the only set theoretic functions that are overlaid in the operations records for matrix algebras and unital matrix algebras. See Set Theoretic Functions for Algebras for an overview of set theoretic functions for general algebras.

No vector space functions are overlaid in the operations records for matrix algebras and unital matrix algebras. The functions for vector space bases are mainly the same as those for row space bases (see Bases for Matrix Algebras).

For other functions for matrix algebras, see Algebra Functions for Matrix Algebras.

## 41.6 Algebra Functions for Matrix Algebras

`Centralizer( A, a )`

`Centralizer( A, S )` :

returns the element or subalgebra centralizer in the matrix algebra A. Centralizers in matrix algebras are computed by solving a linear equation system.

`Centre( A )` :

returns the centre of the matrix algebra A, which is computed by solving a linear equation system.

`FpAlgebra( A )` :

returns a finitely presented algebra that is isomorphic to A. The presentation is computed using the structure constants, thus a vector space basis of A has to be computed. If A contains no multiplicative neutral element (see Zero and One for Matrix Algebras) an error is signalled. (At the moment the implementation is really simpleminded.)

```    gap> a:= UnitalAlgebra( Rationals, [[[0,1],[0,0]]] );
UnitalAlgebra( Rationals, [ [ [ 0, 1 ], [ 0, 0 ] ] ] )
gap> FpAlgebra( a );
UnitalAlgebra( Rationals, [ a.1 ] )
gap> last.relators;
[ a.1^2 ] ```

## 41.7 RepresentativeOperation for Matrix Algebras

`RepresentativeOperation( A, v1, v2 )`

returns the element in the matrix algebra A that maps v1 to v2 via right multiplication if such an element exists, and `false` otherwise. v1 and v2 may be vectors or matrices of same dimension.

```    gap> a:= MatAlgebra( GF(2), 2 );
UnitalAlgebra( GF(2), [ [ [ Z(2)^0, 0*Z(2) ], [ 0*Z(2), 0*Z(2) ] ],
[ [ 0*Z(2), Z(2)^0 ], [ Z(2)^0, 0*Z(2) ] ] ] )
gap> v1:= [ 1, 0 ] * Z(2);; v2:= [ 1, 1 ] * Z(2);;
gap> RepresentativeOperation( a, v1, v2 );
[ [ Z(2)^0, Z(2)^0 ], [ Z(2)^0, Z(2)^0 ] ]
gap> t:= TrivialSubalgebra( a );;
gap> RepresentativeOperation( t, v1, v2 );
false ```

## 41.8 MatAlgebra

`MatAlgebra( F, n )`

returns the full matrix algebra of n by n matrices over the field F.

```    gap> a:= MatAlgebra( GF(2), 2 );
UnitalAlgebra( GF(2), [ [ [ Z(2)^0, 0*Z(2) ], [ 0*Z(2), 0*Z(2) ] ],
[ [ 0*Z(2), Z(2)^0 ], [ Z(2)^0, 0*Z(2) ] ] ] )
gap> Size( a );
16 ```

## 41.9 NullAlgebra

`NullAlgebra( F )`

returns a trivial algebra (that is, it contains only the zero element) over the field F. This occurs in a natural way whenever `Operation` (see Operation for Algebras) constructs a faithful representation of the zero module.

Here we meet the strange situation that an operation algebra does not consist of matrices, since in GAP3 a matrix always has a positive number of rows and columns. The element of a `NullAlgebra( F )` is the object `EmptyMat` that acts (trivially) on empty lists via right multiplication.

```    gap> a:= NullAlgebra( GF(2) );
NullAlgebra( GF(2) )
gap> Size( a );
1
gap> Elements( a );
[ EmptyMat ]
gap> [] * EmptyMat;
[  ]
gap> IsAlgebra( a );
true ```

## 41.10 Fingerprint

`Fingerprint( A )`
`Fingerprint( A, list )`

returns the fingerprint of the matrix algebra A, i.e., a list of nullities of six ``standard'' words in A (for 2-generator algebras only) or of the words with numbers in list.

```    gap> m1:= PermutationMat( (1,2,3,4,5), 5, GF(2) );;
gap> m2:= PermutationMat( (1,2)      , 5, GF(2) );;
gap> a:= Algebra( GF(2), [ m1, m2 ] );;
gap> Fingerprint( a );
[ 1, 1, 1, 3, 0, 4 ] ```

Let a and b be the generators of a 2-generator matix algebra. The six standard words used by `Fingerprint` are w1, w2, ..., w6 where

 w1 = a b + a + b, w2 = w1 + a b2, w3 = a + b w2, w4 = b + w3, w5 = a b + w4, w6 = a + w5

## 41.11 NaturalModule

`NaturalModule( A )`

returns the natural module M of the matrix algebra A. If A consists of n by n matrices, and F is the coefficients field of A then M is an n-dimensional row space over the field F, viewed as A-right module (see Module).

```    gap> a:= MatAlgebra( GF(2), 2 );;
gap> a.name:= "a";;
gap> m:= NaturalModule( a );
Module( a, [ [ Z(2)^0, 0*Z(2) ], [ 0*Z(2), Z(2)^0 ] ] ) ```

gap3-jm
19 Feb 2018