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

Sven Reichard sven.reichard at tu-dresden.de
Mon Dec 14 14:00:12 GMT 2015


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.

Sven Reichard



On 12/14/2015 02:34 PM, Benoit Jacob wrote:
> Hello,
> 
> What would be a simple way to write a "for" loop iterating over all square
> matrices of a fixed size, say NxN, over some fixed finite field GF(q) ?  So
> there would be q^(N^2) iterations? - of course, one could write a for loop
> over integers from 1 to q^(N^2) and for each integer construct a
> corresponding matrix, but is there a simpler way?
> 
> Thanks,
> Benoit
> _______________________________________________
> Forum mailing list
> Forum at mail.gap-system.org
> http://mail.gap-system.org/mailman/listinfo/forum
> 



More information about the Forum mailing list