Obtaining symmetric matrices in GAP

59 Views Asked by At

Let $X$ be a finite set of integers.

Question: Is there a fast way to obtain all symmetric $n \times n$ matrices with entries in $X$ in GAP?

I try to obtain this set of matrices for example for $n=5$ and $X= \{-1,0,1 \}$ but I get "Error, reached the pre-set memory limit" using GAP. So I wonder whether there is a quick way to obtain such matrices that might be possible also for $n=5$ ($n=4$ takes some minutes).

1

There are 1 best solutions below

0
On

Symmetric matrices form a vector space and you can use vector space functionality to construct them. E.g. for $n=2$ and the field with $3$ elements:

gap> bas:=[[[1,0],[0,0]],[[0,1],[1,0]],[[0,0],[0,1]]]*One(GF(3));;
gap> v:=VectorSpace(GF(3),bas);
<vector space over GF(3), with 3 generators>
gap> e:=Enumerator(v);
<enumerator of <vector space of dimension 3 over GF(3)>>
gap> Length(e);
27
gap> Display(e[15]);
 1 1
 1 2

You can use this enumerator e like a list, but it uses far less memory. Converting from finite field to integer entries will be easy.