This section intends to show you the things you could do with matrix groups in GAP. In principle all the set theoretic functions mentioned in chapter Domains and all group functions mentioned in chapter Groups can be applied to matrix groups. However, you should note that at present only very few functions can work efficiently with matrix groups. Especially infinite matrix groups (over the rationals or cyclotomic fields) can not be dealt with at all.
Matrix groups  are created in the same  way as the other types of groups,
by using the function Group.  Of  course,  in this case  the  arguments
have to be invertable matrices over a field.
    gap> m1 := [ [ Z(3)^0, Z(3)^0, Z(3) ],
    >             [ Z(3), 0*Z(3), Z(3) ],
    >             [ 0*Z(3), Z(3), 0*Z(3) ] ];;
    gap> m2 := [ [ Z(3), Z(3), Z(3)^0 ],
    >            [ Z(3), 0*Z(3), Z(3) ],
    >            [ Z(3)^0, 0*Z(3), Z(3) ] ];;
    gap> m := Group( m1, m2 );
    Group( [ [ Z(3)^0, Z(3)^0, Z(3) ], [ Z(3), 0*Z(3), Z(3) ],
      [ 0*Z(3), Z(3), 0*Z(3) ] ],
    [ [ Z(3), Z(3), Z(3)^0 ], [ Z(3), 0*Z(3), Z(3) ],
      [ Z(3)^0, 0*Z(3), Z(3) ] ] )
As usual for groups, the matrix group that we have constructed is represented by a record with several entries. For matrix groups, there is one additional entry which holds the field over which the matrix group is written.
    gap> m.field;
    GF(3)
Note that  you  do not specify  the field  when you construct the  group.
Group  automatically  takes  the  smallest field  over  which  all  its
arguments can be written.
At this point there is the question what  special functions are available
for matrix groups.  The size of our group, for  example, may  be computed
using the function Size.
    gap> Size( m );
    864
If we now compute the size of the corresponding general linear group
    gap> (3^3 - 3^0) * (3^3 - 3^1) * (3^3 - 3^2);
    11232
we see that we have constructed a proper subgroup of index 13 of GL(3,3).
Let  us now set  up a subgroup of  m, which  is generated by the matrix
m2.
    gap> n := Subgroup( m, [ m2 ] );
    Subgroup( Group( [ [ Z(3)^0, Z(3)^0, Z(3) ], [ Z(3), 0*Z(3), Z(3) ],
      [ 0*Z(3), Z(3), 0*Z(3) ] ],
    [ [ Z(3), Z(3), Z(3)^0 ], [ Z(3), 0*Z(3), Z(3) ],
      [ Z(3)^0, 0*Z(3), Z(3) ] ] ),
    [ [ [ Z(3), Z(3), Z(3)^0 ], [ Z(3), 0*Z(3), Z(3) ],
          [ Z(3)^0, 0*Z(3), Z(3) ] ] ] )
    gap> Size( n );
    6
And  to round up  this  example we now  compute the  centralizer  of this
subgroup in m.
    gap> c := Centralizer( m, n );
    Subgroup( Group( [ [ Z(3)^0, Z(3)^0, Z(3) ], [ Z(3), 0*Z(3), Z(3) ],
      [ 0*Z(3), Z(3), 0*Z(3) ] ],
    [ [ Z(3), Z(3), Z(3)^0 ], [ Z(3), 0*Z(3), Z(3) ],
      [ Z(3)^0, 0*Z(3), Z(3) ] ] ),
    [ [ [ Z(3), Z(3), Z(3)^0 ], [ Z(3), 0*Z(3), Z(3) ],
          [ Z(3)^0, 0*Z(3), Z(3) ] ],
      [ [ Z(3), 0*Z(3), 0*Z(3) ], [ 0*Z(3), Z(3), 0*Z(3) ],
          [ 0*Z(3), 0*Z(3), Z(3) ] ] ] )
    gap> Size( c );
    12
In this section you have seen that matrix groups are constructed in the same way that all groups are constructed. You have also been warned that only very few functions can work efficiently with matrix groups. See chapter Matrix Groups to read more about matrix groups.
GAP 3.4.4