Algorithm for getting all 2D necklaces

90 Views Asked by At

Let's assume that we work in the finite field of two elements, $\{0, 1\}$. We want for example to construct all the necklaces of length $N = 3$. Thus, from the full set of ALL PERMUTATIONS (edit:to be clear) $$\{0, 0, 0\}, \{0, 0, 1\}, \{0, 1, 0\}, \{0, 1, 1\}, \{1, 0, 0\}, \{1, 0, 1\}, \{1, 1, 0\}, \{1, 1, 1\}$$ we get the elements (NECKLACES:edited to be clear) $$\{0, 0, 0\}, \{0, 0, 1\}, \{0, 1, 1\}, \{1, 1, 1\}.$$

One efficient way (compared to the brute force method) to get all necklaces is to use Savage's algorithm or its later versions.

What would be the way/algorithm to get all necklaces in $2$D? We assume that the matrix is periodic across the x- and y- dimension. Say we have $(N_x, N_y) = (3, 3)$, then the matrices $$ \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 1 \end{pmatrix}, \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 1 & 0 \end{pmatrix}, \begin{pmatrix} 0 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 0 \end{pmatrix} $$ are equivalent, while the matrices $$ \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}, \begin{pmatrix} 0 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 1 & 0 \end{pmatrix} $$ are not.

What would be the algorithm for getting the necklaces for a given $(N_x, N_y)$?