[GAP Forum] how to iterate over all matrices over a finite field?

Alexander Konovalov alexk at mcs.st-and.ac.uk
Mon Dec 14 14:33:41 GMT 2015


> On 14 Dec 2015, at 14:00, Sven Reichard <sven.reichard at tu-dresden.de> wrote:
> 
> Hello Benoit,
> 
> matrices are tuples of tuples, so we can use the combinatorial
> functions. As we do not want to store the complete list of matrices we
> use an iterator.
> 
> gap> n := 3;; F := GF(3);;
> gap> rows := Tuples(F, n);
> gap> matrices := IteratorOfTuples(rows, n);
> gap> for matrix in matrices do
>>     process(matrix);
>>   od;
> 
> Hope this helps.
> 
> If the set of rows is too large to be stored, the set of matrices is
> likely too large to be processed. However maybe there is also a way of
> avoiding storage of the rows.

Yes, one way to avoid storage of rows is to iterate over the full matrix
algebra:

n := 3;; F := GF(3);;
M:=FullMatrixAlgebra(F,n);
for matrix in M do
  process(matrix);
od;

Hope this helps
Alexander





More information about the Forum mailing list