Next Article in Journal
Control the Coefficient of a Differential Equation as an Inverse Problem in Time
Next Article in Special Issue
Perfect Codes over Non-Prime Power Alphabets: An Approach Based on Diophantine Equations
Previous Article in Journal
The Solid–Liquid Phase Interface Dynamics in an Undercooled Melt with a Solid Wall
Previous Article in Special Issue
Application of Decimated Mathematical Equations and Polynomial Root-Finding Method in Protection of Text Messages
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

How to Find the Equivalence Classes in a Set of Linear Codes in Practice?

by
Stefka Bouyuklieva
1,* and
Iliya Bouyukliev
2
1
Faculty of Mathematics and Informatics, St. Cyril and St. Methodius University of Veliko Tarnovo, 5000 Veliko Tarnovo, Bulgaria
2
Institute of Mathematics and Informatics, Bulgarian Academy of Sciences, 5000 Veliko Tarnovo, Bulgaria
*
Author to whom correspondence should be addressed.
Mathematics 2024, 12(2), 328; https://doi.org/10.3390/math12020328
Submission received: 16 December 2023 / Revised: 14 January 2024 / Accepted: 17 January 2024 / Published: 19 January 2024
(This article belongs to the Special Issue Codes, Designs, Cryptography and Optimization, 2nd Edition)

Abstract

:
An algorithm for equivalence of linear codes over finite fields is presented. Its main advantage is that it can extract exactly one representative from each equivalence class among a large number of linear codes. It can also be used as a test for isomorphism of binary matrices. The algorithm is implemented in the program LCequivalence, which is designed to obtain the inequivalent codes in a set of linear codes over a finite field with q < 64 elements. This program is a module of the free software package QextNewEdition for constructing, classifying and studying linear codes.

1. Introduction

Solving classification problems is of interest for both practical and theoretical reasons. Already, Felix Klein in his Erlanger Programm (1872) [1] described mathematics as the study of properties of sets that remain invariant under certain specified groups of transformations. The classification of codes with given parameters and/or properties is one of the main problems in Coding theory. Two equivalent codes are considered to be the same code, and one can replace the other if it is more convenient in the corresponding practical application. For example, we say that there is only one Reed–Muller [ 32 , 16 , 8 ] binary code, but in fact there are many different codes with these parameters and they are all equivalent to each other. Some algorithms for construction and/or classification of linear codes use the set of all inequivalent codes with smaller parameters and/or given properties. For more theoretical and practical issues of the classification problem we refer to the book of Kaski and Östergård, Classification Algorithms for Codes and Designs [2]. The equivalence test is the main part in any classification algorithm.
In this paper, we describe the algorithm implemented in the program LCequivalence, which can be downloaded from the website [3]. The program uses as input a file with generator matrices of linear codes over a finite field F q with q < 64 elements and gives as output a maximum set of inequivalent codes among them. Moreover, it calculates the order of the automorphism group of a codes and presents the orbits of the coordinates with respect to this group.
Although there are many classification results, the known algorithms for equivalence of linear codes that are implemented in a software are the algorithm of J. Leon [4] (implemented in Magma [5] and GAP [6]), the algorithm of Thomas Feulner [7] (implemented in SageMath [8]) and Bouyukliev’s algorithm [9] (implemented in Q-Extension). An algorithm was proposed by N. Sendrier in [10], but his algorithm has mostly theoretical value. There are many papers considering the complexity of the code equivalence problem (we distinguish the papers [11,12]). Each of the respective programs has its advantages and limitations, and in our opinion it is good to have more choice so that users can test and use the software that is most suitable for their particular research.
Leon’s algorithm checks two codes for equivalence and computes automorphism groups. It is implemented in the computer algebra system Magma, which is not freely available, and to compare more codes, a program must be written for it. The same algorithm is implemented in the free computer algebra system GAP, but only for the binary case, i.e., for linear codes over F 2 . Feulner’s program can only be used via the computer algebra system SageMath (as far as we know), so if one wants to use this algorithm one must be familiar with that system. The algorithm implemented in Q-Extension works with codes over fields with up to 5 elements.
As main advantages of the program LCequivalence, we can point out the following: (1) it can be used to find the inequivalent among a huge number of linear codes; (2) it works for codes over prime and composite fields with q < 64 elements; (3) the limits on the length and dimension of the considered codes depend only on the used hardware and the computational time (not on the algorithm). As far as we know, there is no other program for the equivalence test of a large number of linear codes. The algorithms implemented in popular packages for computations with linear codes, such as Magma and GAP package GUAVA, check pairs of codes for equivalence, and if the researcher needs to test more codes, he/she has to write a program to use this check.
The main idea of the algorithm is to associate each code (regardless of what field it is over) with a binary matrix, so that two codes are equivalent if and only if the corresponding binary matrices are isomorphic. A similar idea was used in [9], but the problem there is that not every automorphism of the binary matrix used is an automorphism of the code, therefore additional verification is needed.
Algebraically, an equivalence relation can be considered in terms of the action of a finite group G on a set of objects Ω . Then, the equivalence classes coincide with the orbits under this action, so two objects are equivalent if and only if they belong to the same orbit of G on Ω [2]. The efficiency of some algorithms depends mostly on the order of the group G, and if it is too large, the equivalence test becomes a very hard problem.
We use an algorithm that involves obtaining canonical forms for the objects using a canonical representative map. To check whether X Y we only need to compare their canonical forms. This approach is used in [9,13]. In most cases, algorithms of this type are more efficient and faster.
The paper is organized as follows. In Section 2, we present some important definitions that we need in our research. In Section 3, we discuss the representation of the linear codes as binary matrices. This representation is very important for the algorithm which is described in the following Section 4. Some computational results are shown in Section 5. In the end, before the references, we give a small conclusion.

2. Preliminaries

In this section, we present the most important definitions that we need in our work. By F q n , we denote the n-dimensional vector space over the finite field F q with q elements. As a metric, we use the Hamming distance between two vectors of F q n , which is defined as the number of coordinates in which they differ. Any k-dimensional linear subspace of F q n is called a linear code of length n and dimension k. The vectors in a code are called codewords, and the minimum among the distances between two different codewords is called the minimum distance of the code. If a linear code over F q has length n, dimension k and minimum distance d, we say that it is an [ n , k , d ] q code. Any matrix of rank k whose rows are codewords from C is called its generator matrix.
Definition 1.
We say that two linear q-ary codes C 1 and C 2 of the same length and dimension are equivalentif the codewords of C 2 can be obtained from the codewords of C 1 via a finite sequence of transformations of the following types:
(1) 
Permutation of coordinate positions;
(2) 
Multiplication of the elements in a given position by a non-zero element of the field;
(3) 
Application of a field automorphism to the elements in all coordinate positions.
This definition is well motivated as the transformations (1)–(3) preserve the Hamming distance and the linearity (for more details see [2], Chapter 7.3). It is based on the action of the semilinear isometries group M n * ( q ) = Mon n ( F q * ) Aut ( F q ) Γ n ( F q ) on the vector space F q n , where Γ n ( F q ) is the set of all semilinear mappings, i.e., the general semilinear group Mon n ( F q * ) is the group of all monomial n × n matrices over F q , and Aut ( F q ) is the automorphisms group of the field F q . Note that the group Mon n ( F q * ) is isomorphic to the wreath product F q * S n , and any monomial matrix is a product of a permutation matrix P and a diagonal matrix D = d i a g ( d 1 , , d n ) , where d i F q * , i = 1 , , n . Linear q-ary codes C 1 and C 2 of the same length n are equivalent whenever C 2 = C 1 T for some T M n * ( q ) . If C T = C for an element T M n * ( q ) , then T is called an automorphism of the code C. The set of all automorphisms of C form a group denoted by Aut ( C ) .
Any element T M n * ( q ) can be written as T = P D τ where P is a permutation matrix (permutation part), D is a diagonal matrix (diagonal part) and τ A u t ( F q ) . Note that in the case of prime q, M n * ( q ) = Mon n ( F q * ) , and if q = 2 , then M n * ( q ) S n , where S n is the symmetric group of degree n.
To construct all inequivalent codes with given parameters means to have one representative of each equivalence class. To easily make a distinction between the equivalence classes, we use the concept for a canonical representative, selected on the base of some specific conditions.
Let G be a group acting on a set Ω . This action defines an equivalence relation such that the equivalence classes are the G-orbits in Ω .
Definition 2.
A canonical representative map for the action of the group G on the set Ω is a function ρ : Ω Ω that satisfies the following two properties:
1. 
For all X Ω it holds that ρ ( X ) X ;
2. 
For all X , Y Ω it holds that X Y implies ρ ( X ) = ρ ( Y ) .
For X Ω , ρ ( X ) is called the canonical form of X, and ρ ( X ) is the canonical representative of its equivalence class with respect to ρ.
In our case, the set Ω consists of linear codes, and we can take for a canonical representative of one equivalence class a code which is more convenient for our purposes.
In addition, we use integer-valued invariants. An invariant over the set E (we use the set of integers Z ) is a mapping f : Ω E such that f ( a ) = f ( b ) if a and b are in the same orbit with respect to the action of the group G. We use two different actions:
(1)
We take Ω to be the set of all linear [ n , k ] q codes (with additional restrictions if needed, for example, only self-orthogonal codes with these parameters or codes with a given minimum and dual distance, etc.) and G = M n * ( q ) .
(2)
For the second action, we take Ω to be the set of all codewords of a linear code C, and the group G = A u t ( C ) . The main invariant that we use in this case is the weight of the codewords.
Finding the canonical form is generally not difficult, but since it is time-consuming, it is important which canonical representation we choose and how we design the algorithm to calculate it. In this work, we do not present a new algorithm for computing canonical forms, but use the algorithm algorithm described in [9]. If the coordinates are previously partitioned according to suitable invariants, the algorithm works much faster. An invariant of the coordinates of C is a function f : N = { 1 , 2 , , n } Z , such that if i and j are in the same orbit with respect to A u t ( C ) then f ( i ) = f ( j ) , i , j N . The code C and the invariant f define a partition π = { N 1 , N 2 , , N l } of the coordinate set N, such that N i N j = for i j , N = N 1 N 2 N l , and two coordinates i , j are in the same subset of N f ( i ) = f ( j ) . The description of some very effective invariants and the process of their application are detailed in [9,13].
To define pseudoorbits and coloring, we consider a set of invariants for the codewords of C. The automorphism group A u t ( C ) acts on the code and partitions the codewords into orbits. All codewords with the same value of an invariant f define a set which consists of one or more orbits called a pseudoorbit. The values of f give an ordering of the pseudoorbits and a coloring of the codewords (the codeword u C has color f ( u ) ). The most natural invariant for a codeword is its weight.
As already mentioned, we associate with each q-ary linear code a binary matrix such that two codes are equivalent if and only if the corresponding binary matrices are isomorphic. Therefore, we need a definition for isomorphism of binary matrices.
Definition 3.
Two binary matrices of the same size are isomorphic if the rows of the second one can be obtained from the rows of the first one by a permutation of the columns.
We also use a similar definition for the equivalence of integer matrices.
Definition 4.
Two integer matrices A and B of the same size are isomorphic ( A B ) if the rows of the second one can be obtained from the rows of the first one by a permutation of the columns.
Any permutation of the columns of an integer (or binary) matrix A which maps the rows of A into the rows of the same matrix is called an automorphism of A. The set of all automorphisms of A is a subgroup of the symmetric group S n , denoted by A u t ( A ) .

3. Representing the Objects

To check codes for equivalence, we need (1) to find a proper set M ( C ) of codewords, (2) to set a binary matrix G M ( C ) corresponding to M ( C ) (if the code is not binary) and (3) to compute the canonical form of G M ( C ) . The set M ( C ) of codewords of the code C must have the following properties:
  • M ( C ) generates the code C;
  • M ( C ) is stable with respect to A u t ( C ) ;
  • If C C and σ ( C ) = C then σ ( M ( C ) ) M ( C ) , σ M n * .
We begin with an algorithm for finding a proper set M ( C ) :
  • Initialization: M ( C ) = ;
  • generate the set D of all codewords with smallest not considered weight;
  • Find and order pseoudoorbits { O 1 , O 2 , , O l } of D according to the value of the applied invariant;
  • For r from 1 to l do the following:
    If rank ( M ( C ) O r ) > rank ( M ( C ) ) , then M ( C ) = M ( C ) O r ;
  • If rank ( M ( C ) ) < rank ( C ) , then go to point 2 else return.
Since the set M ( C ) is stable under the action of the automorphism group of the code, together with each vector it contains all its proportional vectors. Let M t be a ( q 1 ) s × n matrix whose rows are the codewords from the set M ( C ) . For any column v of this matrix we add all its proportional column vectors and thus construct the matrix M t e x t with the same number of ( q 1 ) s rows but ( q 1 ) n columns. If the codes C and C are equivalent then there is a monomial matrix M Mon n ( F q * ) and an automorphism of the field ϕ such that v M ϕ C for any codeword v C . It turns out that M t · M ϕ = P · M t , where P is a permutation matrix that permutes the rows of M t . Since in the definition for equivalence of integer matrices we use only permutations (resp. permutation matrices), we consider the matrices M t e x t and M t e x t . If we map the monomial matrix M to the permutation ( q 1 ) n × ( q 1 ) n matrix P M by replacing any element with a ( q 1 ) × ( q 1 ) matrix in the following way:
0 c i r c ( 00 0 ) , α i c i r c ( 0 0     1     i 0 0 ) f o r i = 0 , 1 , , q 2 ,
we have M t e x t · P M ϕ = P · M t e x t . This gives us that
P M T · M t e x t T ϕ = M t e x t T · P T M t e x t T · ( P T ) 1 ϕ = ( P M T ) 1 · M t e x t T .
This means that instead of the matrices M t e x t and M t e x t , we can use their transpose matrices, which is important if s < n .
Example 1.
The ternary codes C = 1 0 1 0 1 2 and C = 1 0 2 0 1 2 are equivalent and the monomial matrix M = 0 0 2 1 0 0 0 1 0 maps the codewords of C to codewords of C . We take
M t = 1 0 1 2 0 2 0 1 2 0 2 1 1 1 0 2 2 0 , M t = 1 0 2 2 0 1 0 1 2 0 2 1 1 2 0 2 1 0 , M t 0 0 2 1 0 0 0 1 0 = 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 M t ,
M t e x t = 1 2 0 0 1 2 2 1 0 0 2 1 0 0 1 2 2 1 0 0 2 1 1 2 1 2 1 2 0 0 2 1 2 1 0 0 , M t e x t = 1 2 0 0 2 1 2 1 0 0 1 2 0 0 1 2 2 1 0 0 2 1 1 2 1 2 2 1 0 0 2 1 1 2 0 0 .
We take only one representative of each class of proportional vectors and thus obtain the set M ( C ) . To define the binary matrix G M ( C ) that corresponds to the set M ( C ) , we consider the cases q = 2 and q 3 separately.
Consider first the binary case. Let G M ( C ) be a binary matrix whose rows are the codewords from M ( C ) .
Theorem 1.
The binary [ n , k ] codes C 1 and C 2 are equivalent if and only if the binary matrices G M ( C 1 ) and G M ( C 2 ) are isomorphic.
Proof. 
Let the binary codes C 1 and C 2 be equivalent. Hence, there is a permutation σ S n such that σ ( C 1 ) = C 2 . It follows that σ ( M ( C 1 ) ) = M ( C 2 ) , therefore the matrices G M ( C 1 ) and G M ( C 2 ) are isomorphic.
Let G M ( C 1 ) G M ( C 2 ) . Then, there is a permutation τ S n such that the matrices τ ( G M ( C 1 ) ) and G M ( C 2 ) have the same rows but are ordered differently. Hence, τ maps the codewords from M ( C 2 ) to codewords in M ( C 2 ) , therefore the codes C 1 and C 2 are equivalent.    □
Representing a linear code over a field with more than two elements as a binary matrix is already introduced in [9,14], but here we present a different approach which is more general and more suitable for codes over fields with q 5 elements.
Let C be a q-ary linear code for with q = p m 3 , where p is a prime, and let α be a primitive element of F q . We map each element of F q to a circular binary matrix of order q 1 in the same way as shown in (1).
Consider the matrix M t ( C ) whose rows are the codewords from M ( C ) for the q-ary linear code C of length n. Replacing all elements in M t ( C ) using (1), we obtain the matrix G M ( C ) of size ( q 1 ) s × ( q 1 ) n where s = | M ( C ) | . Note that this presentation includes also the proportional vectors of the codewords in M ( C ) and ( q 1 ) s = | M ( C ) | .
To construct the needed binary matrix, we use some additional matrices that depend on the field. Denote the ( q 1 ) × ( q 1 ) circulant c i r c ( 010 0 ) by L and let
A * = I q 1 + 2 ( L + L p + + L p m 1 ) .
The automorphism group of this matrix is A u t ( A * ) = σ , τ < S q 1 , where σ = ( 0 , 1 , , q 2 ) is the presented cycle of length q 1 , and τ = Ω 1 Ω t , where Ω i corresponds to the i-th ciclotomic class modulo q 1 . This group is isomorphic to F q * Aut ( F q ) which is the automorphism group of the trivial [ 1 , 1 ] q code. We prove this isomorphism in detail in the following lemma.
Lemma 1.
A u t ( A * ) F q * A u t ( F q ) .
Proof. 
Let us label the rows and the columns of the matrix A * from 0 to q 2 . We first consider the case of a prime q 3 . Then the i-th row of A * is
( 0 , , 0 ,     1     i ,     2     i + 1 , 0 , , 0 ) , for 0 i q 3 ,
and ( 2 , 0 , , 0 , 1 ) if i = q 2 . The j-th column is ( 1 , 0 , , 0 , 2 ) T if j = 0 , and
( 0 , , 0 ,     2     j 1 ,     1     j , 0 , , 0 ) , if 1 j q 2 .
Now, take a permutation τ A u t ( A * ) S q 1 . If τ ( 0 ) = j , then the column with number 0 goes to the j-th column. This column contains only one coordinate equal to 1 and this 1 is on the j-th row which contains only one coordinate equals to 2, namely the j + 1 -th coordinate. Hence, τ ( 1 ) = j + 1 . Considering the j + 1 -th column and the positions of the coordinates equal to 1 and 2, we have τ ( i ) = j + i ( mod q 1 ) . Hence, τ = ( 0 , 1 , , q 2 ) j and A u t ( A * ) = ( 0 , 1 , , q 2 ) F q * .
Let us now consider the general case when q = p m for a prime p and integer m 1 . In this case, if A * = ( a i j ) , 0 i , j q 2 , then a i i = 1 for all i = 0 , 1 , , q 2 , and a i j = 2 if j = i + p s ( mod q 1 ) , s = 0 , 1 , , m 1 . We can consider any automorphism τ A u t ( A * ) S q 1 as a permutation of the nonzero elements of the field. If τ ( α 0 ) = α i , the row with number 0 goes to the i-th row. This means that
{ α , α p , , α p m 1 } τ { α i + 1 , α i + p , , α i + p m 1 }
(these are the positions of the coordinates equal to 2 in these two rows). But then, τ ( α ) = α i + p s 1 and the number 1 row goes to row with number i + p s 1 and therefore
{ α 2 , α 1 + p , , α 1 + p m 1 } τ { α 1 + i + p s 1 , α i + p s 1 + p , , α i + p s 1 + p m 1 } .
Hence, τ ( α 2 ) = α i + p s 1 + p s 2 . Then,
{ α 3 , α 2 + p , , α 2 + p m 1 } τ { α 1 + i + p s 1 + p s 2 , α i + p s 1 + p s 2 + p , , α i + p s 1 + p s 2 + p m 1 } .
Thus, τ ( α 3 ) = α i + p s 1 + p s 2 + p s 3 . In this way we obtain that τ ( α p ) = α i + p s 1 + p s 2 + + p s p . But at the same time, τ ( α p ) = α i + p r and so α i + p s 1 + p s 2 + + p s p = α i + p r . It follows that
α p s 1 + p s 2 + + p s p p r = 1 p m 1 p s 1 + p s 2 + + p s p p r .
But s j m 1 , j = 1 , , p , and r 0 , thus p s 1 + p s 2 + + p s p p r p m 1 . Hence, p s 1 + p s 2 + + p s p p r = 0 or p m 1 . It turns out that s 1 = s 2 = = s p = s , r = s + 1 , and τ ( α j ) = α i + j p s for j = 0 , 1 , , q 2 which means that τ = σ i ϕ s G , where σ = ( 0 , 1 , 2 , , q 2 ) and ϕ is the Frobenius automorphism defined by ϕ ( a ) = a p , a F q . It follows that Aut ( A * ) σ , ϕ F q * Aut ( F q ) .    □
We give two examples with the matrices A * .
Example 2.
Consider the cases q = 5 and q = 8 :
(1) 
If q = 5 we have A * = circ ( 1200 ) = 1 2 0 0 0 1 2 0 0 0 1 2 2 0 0 1 , A u t ( A * ) = ( 0123 ) < S 4 ;
(2) 
If q = 8 then A * = circ ( 1220200 ) = 1 2 2 0 2 0 0 0 1 2 2 0 2 0 0 0 1 2 2 0 2 2 0 0 1 2 2 0 0 2 0 0 1 2 2 2 0 2 0 0 1 2 2 2 0 2 0 0 1 ,
A u t ( A * ) = ( 0123456 ) , ( 124 ) ( 365 ) < S 7 , | A u t ( A * ) | = 21 .
Next, we replace the elements 0, 1 and 2 in the matrix A * with binary column-vectors with two coordinates as follows:
0 0 0 , 1 1 0 , 2 1 1
and in this way from the matrix A * we construct the matrix B . To have a matrix with an automorphism group which is isomorphic to Aut ( A * ) , we expand B with the columns of the matrix I q 1 1 1 , and denote the obtained matrix by B * .
Example 3.
Consider again the case q = 5 . Then,
B * = 1 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 0 1 1 0 0 0 0 0 0 1
Recall that Aut ( A * ) = σ , τ . Let us map σ S q 1 to the permutation σ = ( 0 , 1 , , q 2 ) ( q 1 , q , , 2 q 3 ) S 2 q 2 , and τ to τ = Ω 1 Ω t Ω 1 Ω t S 2 q 2 where τ is defined as follows: if Ω i = ( j 1 , , j m i ) then Ω i = ( q 1 + j 1 , , q 1 + j m i ) , i = 1 , , t . This map defines an isomorphism between Aut ( A * ) and Aut ( B * ) , and so Aut ( B * ) F q * Aut ( F q ) .
We need two more square matrices, namely the ( q 1 ) n × ( q 1 ) n matrix A = I n A * and the 2 ( q 1 ) n × 2 ( q 1 ) n matrix B = ( I n B | I ( q 1 ) n 1 1 ) . The automorphism groups of these two matrices are isomorphic to M n * ( q ) .
Now expand the matrix G M ( C ) by adding the rows of the matrix A. In this way we obtain the matrix G M A ( C ) = G M ( C ) A with ( q 1 ) ( s + n ) rows and ( q 1 ) n columns.
Example 4.
Consider the [ 2 , 1 ] 5 code C with a generator matrix ( 1 2 ) . For this code
G M A ( C ) = 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 1 2 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 1 2 0 0 0 0 2 0 0 1 0 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 1 2 0 0 0 0 2 0 0 1
The automorphism group of the matrix A is isomorphic to M n * ( q ) and therefore Aut ( G M A ( C ) ) < Aut ( A ) and consists of those automorphisms of A which belong to Aut ( G M ( C ) ) .
Example 5.
Consider the code from Example 4. If we swap the two coordinates and then multiply the second coordinate by 4, we obtain the same code. Hence, the monomial matrix 0 4 1 0 belongs to the automorphism group of this code. We map this monomial matrix to the permutation matrix
Q A = 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 .
It is easy to see that the matrix G M A ( C ) Q A has the same rows as the matrix G M A ( C ) and so Q A A u t ( G M A ( C ) ) .
The matrices G M ( C ) and G M A ( C ) are related to the matrix G M B ( C ) which we construct in the following way: (1) we glue the ( q 1 ) s × ( q 1 ) n zero matrix to the matrix G M ( C ) ; (2) we add the rows of B. The obtained matrix has ( q 1 ) ( s + 2 n ) rows and 2 ( q 1 ) n columns.
Example 6.
Consider the same [ 2 , 1 ] 5 code C with a generator matrix ( 1 2 ) . For this code
G M B ( C ) = 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1
Theorem 2.
The q-ary [ n , k ] codes C 1 and C 2 are equivalent if and only if the binary matrices G M B ( C 1 ) and G M B ( C 2 ) are isomorphic.
Proof. 
In converting the matrix M t ( C ) to the matrix G M B ( C ) , we replace each column with a group of ( q 1 ) columns and then extend the obtained matrix with extra zero columns and the rows of the matrix B. Therefore, there is a one-to-one correspondence between the permutations of the coordinates of C and the permutations of the corresponding groups of columns in G M B ( C ) . More precisely, if τ S n is a permutation of the n coordinates of C, it goes to the permutation τ B S 2 ( q 1 ) n of the columns of G M B ( C ) such that if τ ( j ) = i j then τ B ( ( q 1 ) j j 1 ) = ( q 1 ) i j j 1 and τ B ( ( q 1 ) ( n + j ) j 1 ) = ( q 1 ) ( n + i j ) j 1 for 1 j n , 0 j 1 q 2 . Moreover, the multiplication of a coordinate by α i can be considered as applying the permutation σ = ( 0 , 1 , , q 2 ) on the corresponding group of 2 ( q 1 ) columns i times. The automorphism of the field applied to all coordinates of all codewords also can be considered as a permutation of the columns of G M B ( C ) .
The above observation shows that if φ M n ( q ) * maps the code C 1 to C 2 , then the corresponding to φ permutation of the columns of G M B ( C 1 ) maps the rows of this matrix to the rows of G M B ( C 2 ) . Note that ϕ can be considered as a permutation followed by multiplications of the coordinates of the code by nonzero elements of the field and eventually applying an automorphism of the field to all coordinates of all codewords.
Conversely, if we take a permutation π of the columns of G M B ( C 1 ) that maps the rows of this matrix to the rows of G M B ( C 2 ) , then π Aut ( B ) M n * ( q ) and π maps the rows of G M ( C 1 ) to the rows of G M ( C 2 ) .    □
Corollary 1.
A u t ( C ) A u t ( G M B ( C ) ) .
Example 7.
The automorphism group of the code C = ( 1 , 2 ) F 5 2 is
A u t ( C ) = { β I 2 , β 0 4 1 0 , β F 5 * } , | A u t ( C ) | = 8 .
According to Corollary 1, A u t ( C ) A u t ( G M B ( C ) ) . Indeed,
A u t ( G M B ( C ) ) = ( 1 , 2 , 3 , 4 ) ( 5 , 6 , 7 , 8 ) ( 9 , 10 , 11 , 12 ) ( 13 , 14 , 15 , 16 ) ,
( 1 , 7 , 3 , 5 ) ( 2 , 8 , 4 , 6 ) ( 9 , 15 , 11 , 13 ) ( 10 , 16 , 12 , 14 ) A u t ( C ) .
Calculating | A u t ( G M ( C ) ) | = 384 , | A u t ( G M A ( C ) ) | = 8 , | A u t ( G M B ( C ) ) | = 48 , where G M B ( C ) is the matrix G M B ( C ) without the last n ( q 1 ) columns, we see that the extra rows and columns are important to remove the automorphisms of the matrices that do not correspond to automorphisms of the code.

4. The Algorithm

The classification problem we want to solve is the following: given a set of linear q-ary codes of length n and dimension k, take only one representative of each equivalence class. We present the algorithm that gives a solution of the problem. As an input, we have a family of linear codes presented by a generator matrix. The set of these matrices is denoted by W. As an output, we have one representative of each equivalence class with respect to the defined (in the previous sections) equivalence relation in the set of linear codes. Generator matrices of these representatives compose the set U. The algorithm follows these steps:
  • We find a generating set M ( C ) for each code C. In most cases this is the set of codewords with minimum weight. If this set has a rank smaller than k, we add the codewords with another weight, etc. In some cases we also use other invariants to get a smaller and more convenient generating set.
  • We take the binary matrix G M B ( C ) as it is described in the previous section. According to Theorem 2, two codes C 1 and C 2 are equivalent if and only if G M B ( C 1 ) G M B ( C 2 ) .
  • We find the canonical form of the matrix G M B ( C ) as it is described in [9].
  • We compare the canonical forms of the matrices. If two matrices have the same canonical form, they are isomorphic and the corresponding codes are equivalent. If these matrices have different canonical forms, the codes are not equivalent.
A pseudocode of Algorithm 1 is given below.
Algorithm 1 Procedure Find_Inequivalent_Codes
Input: 
A set W of generator matrices of linear codes.
Output: 
A maximal set U W of generator matrices of inequivalent codes.
     
var
     
HA: array of integers;
     
Hf: file;
     
not_found: boolean;
  1:
Initialize Hf;
  2:
H A [ i ] 0 for all i = 0 , , s i z e ;
  3:
for each generator matrix G W  do
  4:
   Find generating set M ( C ) of the corresponding linear code C;
  5:
   construct the corresponding binary matrix G M B ( C ) ;
  6:
   find the canonical form A the matrix G M B ( C ) and its hash value h ( A ) ;
  7:
   call the procedure SEARCH_IN_HASH_TABLE with parameters H A , A, h ( A ) , H f
   {the procedure gives the value of the boolean variable n o t _ f o u n d which is true or false}
  8:
   if  n o t _ f o u n d  then
  9:
    U U { G }
10:
   end if
11:
end for
For fast search between a large number of similar objects (in our case, binary matrices in canonical form), an abstract data structure known as a hash map is used (more information about hash tables and hash maps can be found in [15,16]). It consists of three components: a hash array, a hash function and a hash table or file. The basic idea is that when we get a new code, we first compare its hash with the hash values of already considered codes. If the new hash is different from all already computed, the new code is not equivalent to either of the previous codes. If the hash is equal to the hash value of another code, then we compare the corresponding binary matrices.
Let us introduce the hashing we use in a little more detail. A hash array H A [ ] can be considered as an array of non-negative integers. To any object, the hash function associates an integer, which can be considered as an index in the hash array H A [ ] . Each element of the array H A [ i ] (if H A [ i ] 0 ) is a pointer (a positive integer) to the location of the object in a hash file or table. In the beginning, all values in the array H A are 0s. We define a hash file as an addressable memory of a large size that consists of cells. Objects or records (that contain an object) can be written in these cells. A binary file which has direct access, or a dynamic structure (if enough RAM is available), can serve as the hash file (hash table).
We use a non-cryptographic hash function h that maps an object of arbitrary size to a positive integer not larger than the size of the hash array. If the number of different matrices we examine is greater than the size of the hash array, there will be at least two matrices with the same hash value, which is called a collision. The hash function h must meet the following requirements:
  • The function should be easily and quickly calculated.
  • It should provide a uniform distribution in the hash array. In this case, the number of collisions will be smaller. Even with a very good hash function, collisions are not excluded. The collision handling technique which we use is known as Separate Chaining (Open Hashing). It is usually implemented using linked lists. A nonzero cell of the hash array points to the first object in a linked list of objects that have the same hash value (if no matches with the same hash value are found, the list consists of one element).
An implementation of this approach is presented in Algorithm 2.
The total complexity of the main algorithm depends on the size of the set of codes (the set W consists of their generator matrices) but is difficult to determine because it depends on many subalgorithms. For codes with large dimension, one of the most expensive parts is the generating a proper set M ( C ) of codewords. In this case, a more efficient approach than the standard brute force algorithm (with Gray code) gives the Brouwer–Zimmermann algorithm and its modifications [17]. The construction of the binary matrix G M B ( C ) , which corresponds to the set M ( C ) , despite its theoretical complexity, practically does not affect the execution time of the algorithm. Finding the canonical form of a binary matrix represents the solution to the graph isomorphism problem, since in this case a bipartite graph is considered. The computation time required depends on whether the binary matrix corresponds to a regular structure such as a combinatorial design and does not particularly depend on the order of the automorphism group. The use of a canonical form reduces the isomorphism problem between binary matrices to a matrix comparison problem which has complexity fixed by the matrix parameters and negligible execution time. In the case of a large number m of non-equivalent matrices, if a hash map is not used, the complexity of comparing a matrix with the others becomes linear with respect to m, and when a hash map is used, the complexity is reduced to a constant.
Algorithm 2 Procedure SEARCH_IN_HASH_TABLE
Input: 
h a s h k e y = h ( A ) , the matrix A, the integer array H A , the file H f
Output: 
n o t _ f o u n d : boolean;
   
type
   
structure MATREC {
   
  matrix M;
   
     integer  N e x t }    // next matrix with the same hashkey
   
var
   
A M A T R E C , B M A T R E C of type MATREC;
   
c u r e n t _ p o s i t i o n , o l d _ p o s i t i o n : integer;
  1:
A M A T R E C . M A ;
  2:
A M A T R E C . n e x t 0 ;
  3:
if  H A [ h a s h k e y ] = 0  then
  4:
   append A M A T R E C to the file H f ;
  5:
    H A [ h a s h k e y ] the position of A M A T R E C in the file H f ;
  6:
   return  n o t _ f o u n d t r u e
  7:
else
  8:
    c u r e n t _ p o s i t i o n H A [ h a s h k e y ] ;
  9:
   while  c u r e n t _ p o s i t i o n 0  do
10:
    o l d _ p o s i t i o n c u r e n t _ p o s i t i o n ;
11:
   read from c u r e n t _ p o s i t i o n the structure B M A T R E C {from the file H f };
12:
    c u r e n t _ p o s i t i o n B M A T R E C . n e x t
13:
   if  A M A T R E C . M = B M A T R E C . M  then
14:
   return  n o t _ f o u n d f a l s e
15:
   end if
16:
   end while
17:
   append A M A T R E C to the file H f ;
18:
    c u r e n t _ p o s i t i o n the first position of A M A T R E C in the file H f ;
19:
    B M A T R E C . N e x t c u r e n t _ p o s i t i o n ;
20:
   write from o l d _ p o s i t i o n the structure B M A T R E C to the file H f
21:
   return  n o t _ f o u n d t r u e ;
22:
end if

5. Computational Results

We made some experiments with codes with different lengths and dimensions over different finite fields.
In Table 1, we present the execution times for obtaining inequivalent codes. In the table, we have presented results in the following cases, which we consider to be significant:
  • Finding the inequivalent codes in a set of randomly constructed linear codes. This is useful for the process of generating linear codes of a given type and/or given parameters. During the intermediate steps in the generation process, a large amount of codes is usually constructed, from which only the inequivalent ones should be taken and the procedure continued with them. As an example, we can mention one of the methods for isomorph-free exhaustive generation, namely isomorph rejection based on recorded objects [2].
  • One of the most important classes of linear codes for theoretical and practical reasons is the class of self-dual codes. A self-dual code over F q is a linear code which coincides with its orthogonal complement in the vector space F q n with respect to a given inner product [18]. The study of these codes involves the generation and classification of self-dual codes over a given finite field with prescribed length, minimum distance and other parameters such as a weight enumerator or an automorphism group (see, for example, [19]). Therefore, we have included in the table results on this type of codes over fields with 3, 5 and 7 elements.
  • The quasi-cyclic codes have nontrivial automorphism groups that contain as a subgroup a cyclic group of a given order (see [18] for more details about these codes). This is the reason why we also consider these types of codes and include a special option in the LCequivalence program to generate random quasi-cyclic codes.
Table 1 is structured as follows. The first three columns contain the parameters n (length), k (dimension) and q (size of the field) of the constructed [ n , k ] q codes. In the fourth column we present the number of constructed codes that will be checked for equivalence. The next column contains the number of the inequivalent codes in the given set of codes. The execution time is shown in the sixth column. In the last column we comment on whether the constructed codes are of special types, for example self-dual or quasi-cyclic.
The computations were executed on a Windows 11 OS in a single core of an Intel Xeon Gold 5118 CPU with a 2.30 GHz clock frequency.
The program LCequivalence has two options for constructing random codes—for given positive integers , n, k, d and q, (1) constructing random linear [ n , k , d ] q codes and (2) constructing random quasi-cyclic [ n , k , d ] q codes. We have provided this option so that we can test a large number of random codes for equivalence. The self-dual codes that we check for equivalence are taken from the Database of self-dual codes by Masaaki Harada and Akihiro Munemasa [20].
As input we use generator matrices of the considered codes. The program then goes through the four steps presented in Section 4 and takes exactly one representative from each equivalence class. Generator matrices of these representatives, as well as additional information about them (parameters, automorphism groups, orbits, etc.), are written to a file.

6. Conclusions

This paper is devoted to the algorithm for equivalence of linear codes over finite fields implemented in the program LCequivalence, which is a module of the software package QextNewEdition v1.1 [3]. The program takes as input a file with generator matrices of linear codes and gives as output a file with generator matrices for the maximum set of inequivalent among the input codes. Using this program, one can test for equivalence codes over fields with q < 64 elements. As can be seen in Table 1, the file may contain large number of codes. As far as we know, there is no other program for the equivalence test of a large number of linear codes. The algorithms implemented in the popular packages that deal with linear codes check pairs of codes for equivalence.
Instead of linear codes, the program LCequivalence can test binary matrices for equivalence. This means that it can be used for equivalence (isomophism) testing of objects that can be represented by binary matrices including graphs [14].
The program also gives the orders and generators of the automorphism groups of the corresponding binary matrices. Optionally, by marking the corresponding option, the program can also write additional information to the output file, such as a permutation that leads one matrix to its equivalent, orbits, weight distributions of the codes, etc.
No installation of the program is required. It is only necessary for the user to create a directory and download a version of the program that corresponds to the operating system used—Linux or Windows. The interface is very simple. The user can choose from the following seven options:
  • Find inequivalent codes.
  • Find inequivalent matrices.
  • What to print in the output file about codes?
  • What to print in the output file about matrices?
  • Change the name of the input file.
  • Random codes (will be written in a file with name EXAM in the directory RES_DIR0).
  • Random quasi-cyclic codes (will be written in a file with name EXAM in the directory RES_DIR0).
As an input the program LCequivalence uses a text file with generator matrices of linear codes in the form described in the previous version of Q-Extension. There is no limit to the number of codes in the input file.

Author Contributions

Conceptualization, I.B.; methodology, I.B.; software, I.B.; validation, I.B. and S.B.; formal analysis, S.B.; resources, I.B. and S.B.; data curation, I.B.; writing—original draft preparation, S.B.; writing—review and editing, S.B.; project administration, I.B. and S.B.; funding acquisition, I.B. and S.B. All authors have read and agreed to the published version of the manuscript.

Funding

This research was partially supported by Bulgarian National Science Fund grant number KP-06-H62/2/13.12.2022.

Data Availability Statement

No new data were created or analyzed in this study. Data sharing is not applicable to this article.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Klein, F. Das Erlanger Programm (1872). In Vergleichende Betrachtungen über Neuere Geometrische Forschungen, 3rd ed.; Harri Deutsch: Frankfurt am Main, Germany, 1997. [Google Scholar]
  2. Kaski, P.; Östergård, P. Classification Algorithms for Codes and Designs; Springer: Berlin/Heidelberg, Germany, 2006. [Google Scholar]
  3. Bouyukliev, I. QextNewEditionLCequivalence Module. Available online: http://www.moi.math.bas.bg/moiuser/~data/Software/QextNewEditionLCequiv.html (accessed on 15 December 2023).
  4. Leon, J. Computing automorphism groups of error-correcting codes. IEEE Trans. Inform. Theory 1982, 28, 496–511. [Google Scholar] [CrossRef]
  5. Bosma, W.; Cannon, J.; Playoust, C. The Magma algebra system I: The user language. J. Symb. Comput. 1997, 24, 235–265. [Google Scholar] [CrossRef]
  6. The GAP Group: GAP–Groups, Algorithms, and Programming, Version 4.12.2. 2022. Available online: https://www.gap-system.org (accessed on 15 December 2023).
  7. Feulner, T. The automorphism groups of linear codes and canonical representatives of their semilinear isometry classes. Adv. Math. Commun. 2009, 3, 363–383. [Google Scholar] [CrossRef]
  8. SageMath. Open-Source Mathematical Software System. Available online: https://www.sagemath.org/ (accessed on 15 December 2023).
  9. Bouyukliev, I. About the code equivalence. In Advances in Coding Theory and Cryptology; Shaska, T., Huffman, W., Joyner, D., Ustimenko, V., Eds.; World Scientific Publishing: Singapore, 2007; pp. 126–151. [Google Scholar]
  10. Sendrier, N. Finding the permutation between equivalent linear codes: The support splitting algorithm. IEEE Trans. Inform. Theory 2000, 46, 1193–1203. [Google Scholar] [CrossRef]
  11. Petrank, E.; Roth, R. Is code equivalence easy to decide? IEEE Trans. Inform. Theory 1997, 43, 1602–1604. [Google Scholar] [CrossRef]
  12. Sendrier, N.; Simos, D. How easy is code equivalence over Fq? In Proceedings of the 8th International Workshop on Coding Theory and Cryptography WCC 2013, Bergen, Norway, 15–19 April 2013.
  13. McKay, B.; Piperno, A. Practical graph isomorphism, II. J. Symb. Comput. 2014, 60, 94–112. [Google Scholar] [CrossRef]
  14. Bouyukliev, I.; Dzhumalieva-Stoeva, M. Representing equivalence problems for combinatorial objects. Serdica J. Comput. 2014, 8, 327–354. [Google Scholar] [CrossRef]
  15. Sedgewick, R.; Wayne, K. Algorithms, 4th ed.; Addison-Wesley Professional: Boston, MA, USA, 2011; Volume 1. [Google Scholar]
  16. Cormen, T.H.; Leiserson, C.E.; Rivest, R.L.; Stein, C. Chapter 11: Hash Tables, in Introduction to Algorithms, 4th ed.; MIT Press: Cambridge, MA, USA; McGraw-Hill: New York, NY, USA, 2022. [Google Scholar]
  17. Bouyuklieva, S.; Bouyukliev, I. An Extension of the Brouwer–Zimmermann Algorithm for Calculating the Minimum Weight of a Linear Code. Mathematics 2021, 9, 2354. [Google Scholar] [CrossRef]
  18. Huffman, W.C.; Pless, V. Fundamentals of Error-Correcting Codes; Cambridge University Press: Cambridge, UK, 2003. [Google Scholar]
  19. Huffman, W.C. On the classification and enumeration of self-dual codes. Finite Fields Appl. 2005, 11, 451–490. [Google Scholar] [CrossRef]
  20. Harada, M.; Munemasa, A. Database of Self-Dual Codes. Available online: https://www.math.is.tohoku.ac.jp/~munemasa/selfdualcodes.htm (accessed on 11 January 2024).
Table 1. Execution times (in seconds) for obtaining inequivalent codes in a set of randomly constructed linear codes with the program LCequivalence.
Table 1. Execution times (in seconds) for obtaining inequivalent codes in a set of randomly constructed linear codes with the program LCequivalence.
nkqNumber of CodesNumber of Inequivalent CodesTime in SecondsComment
20102100,00065,56639.47random
4020210,00010,00089.25random
120402100100336.98quasi-cyclic
120402100100214.34random
281436931693115,386.21self-dual
60164100100231.30random
500010410001000153.91random
168553553533.187self-dual
126764640.30self-dual
402072112.44self-dual
562872125,161.18self-dual
15391,000,0004115621.85quasi-cyclic
201016100010009.87random
2010171000100017.33random
20102310001000110.38random
1000531100100110.39random
1033210,0009999167.81random
20106110010080.59random
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Bouyuklieva, S.; Bouyukliev, I. How to Find the Equivalence Classes in a Set of Linear Codes in Practice? Mathematics 2024, 12, 328. https://doi.org/10.3390/math12020328

AMA Style

Bouyuklieva S, Bouyukliev I. How to Find the Equivalence Classes in a Set of Linear Codes in Practice? Mathematics. 2024; 12(2):328. https://doi.org/10.3390/math12020328

Chicago/Turabian Style

Bouyuklieva, Stefka, and Iliya Bouyukliev. 2024. "How to Find the Equivalence Classes in a Set of Linear Codes in Practice?" Mathematics 12, no. 2: 328. https://doi.org/10.3390/math12020328

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop