ON SOME CLASSES OF CODES WITH A FEW WEIGHTS

. We generalize the code constructed recently by Wang et al, and obtain many classes of codes with a few weights. The weight distribution of these codes is completely determined, and the minimum distance of the duals of these codes is determined. We also show that some subclasses of the duals of these codes are optimal. Furthermore, some parameters of the generalized Hamming weight of these codes are calculated in certain cases.


Introduction
Throughout this paper, let m be a positive integer, and let r be a prime such that 2 is a primitive root modulo r m , that is, 2 is a generator of the multiplicative group of integers modulo r m . Let q = 2 φ(r m ) , where φ is the Euler function. Let γ be a primitive element of F q , where F q denotes the finite field with q elements.
An [n, k, d] binary linear code C is a k-dimensional subspace of F n 2 with minimum Hamming distance d. Let A i denote the number of codewords with Hamming weight i in a code C of length n. The weight enumerator of C is defined by 1 + A 1 y + A 2 y 2 + · · · + A n y n . The sequence (A 1 , A 2 , · · · , A n ) is called the weight distribution of the code C. The weight distribution of a code gives information about the error correcting capability and the probability of error detection and correction with respect to some decoding algorithms.
A code C is t-weight if the number of nonzero A i in the sequence (A 1 , A 2 , · · · , A n ) is equal to t. An [n, k, d] code C is called optimal if no [n, k, d + 1] code exists, and is called almost optimal if the code [n, k, d + 1] is optimal [6,Chapter 2].
Let Tr denote the trace function from F q onto F 2 . For any set A = {a 1 , a 2 , · · · , a n } ⊆ F * q , we define a linear code of length n over F 2 by C A = {(Tr(xa 1 ), Tr(xa 2 ), · · · , Tr(xa n )) : x ∈ F q }, and call A the defining set of C A . It is a basic fact that different orderings of the elements of A result in equivalent codes [6, p.20]. Since equivalent codes have the same weight distribution, we will not specify the ordering of the elements in A when we study the weight distribution of C A .
This construction of C A is generic in the sense that many classes of known codes can be produced by selecting the defining set A ⊆ F * q properly [3], [9], and these codes are useful in secret sharing schemes [1], [2], [13] and authentication codes [4].
The aim of this paper is to generalize the code-constructing method in [9] and [10], and then obtain many new classes of two-weight and three-weight codes, whose duals are either optimal or almost optimal. We will completely determine the weight distribution of these two-weight and three-weight codes, and study the duals of these codes, and further determine the optimal duals of these codes. We will also compute the generalized Hamming weight of these two-weight and three-weight codes in some cases. To get these new results, we will have to develop new techniques which are much different from that in [9] and [10], and these new techniques and new results are main contributions of the paper.

Preliminaries and problem formulation
In this section, we present some results of group characters and exponential sums for later use, please see [7] for details. An additive character χ of F q is a function from F q to the set of complex numbers of absolute value 1 such that defines an additive character of F q , and every additive character of F q can be obtained in this way. When b = 1, the character χ 1 in (1) is called the canonical additive character of F q . It is obvious that χ b (x) = χ 1 (bx). Let α = γ q−1 r m , and for any a, b ∈ F q , define the following exponential sum Then, Since 2 is a primitive root modulo r m , the r m th cyclotomic polynomial is irreducible and is the minimal polynomial of α = γ q−1 r m , then F q = F 2 (α). Express a ∈ F q in basis (α, α 2 , · · · , α φ(r m ) ), say where a j ∈ F 2 for all j = 1, · · · , φ(r m ). For i = 0, 1, · · · , r m−1 − 1, we denote by a (i) the following subvector of length r − 1 of the coordinate vector a = (a 1 , a 2 , · · · , a φ(r m ) ) of a: Let wt(x) denote the Hamming weight of the binary vector x. We get the following two useful lemmas. Lemma 1. ([8], Theorem 1 and Theorem 3) Let a ∈ F q . Then Moreover, there exists a b ∈ F q such that each subvector b (i) is of even weight and S(a) = r m − 2wt(b). S(a) ranges over r m −4j, j = 1, 2, · · · , φ(r m )/2, when a ∈ F * q .
For the defining set Wang et al [9] [10] have recently studied the code C A and determined the weight distribution the code C A and the minimum distance of the dual of C A . Motivated by this result, we will study the code C A , where the defining set A is given by Obviously, C A is a special case of C A by taking a = 1 in (4). In order to obtain the weight distribution of C A , by Lemmas 1 and 2, Wang et al [9] [10] skillfully used the coordinate vector 1 of a = 1 and computed S(1) and S(1, b) directly by discussing the value taken by b. Such a direct computation can't work because of the complexity when the parameter a varies in F * q . Our contributions are to find new techniques to overcome the above difficulties, and our techniques will avoid the tedious computation of S(a) and S(a, b) and obtain a complete description of the code C A .
The paper is organized as follows: in Section 3, we will determine the weight distribution of C A for any pair (a, b). In Section 4, we show that for any pair (a, b), the minimum distance of the dual C ⊥ A of C A is equal to 3, and present some subclasses of the dual code C ⊥ A which are optimal. In Section 5, we will study the generalized Hamming weight of C A for any pair (a, b), and determine some parameters of the generalized Hamming weight in some cases, and then the conclusion in Section 6.

The weight distribution of C A
Let r, m, q (= 2 φ(r m ) ), γ, α and S(a) be defined as before. We will determine the weight distribution of C A in this section. Define Then n 0 − 1 is the codeword length of C A , and for d ∈ F * q , the Hamming weight of the nonzero codeword (5) c d = (Tr(da 1 ), Tr(da 2 ), · · · , Tr(da n0−1 )) (a i ∈ A, i = 1, · · · , n 0 − 1) is equal to n 0 − N d .
By calculating and using the notation S(a, b) in Section 2, we get and Thus, According to (7), we have to compute S(a, b) and S(a, b + d) in order to get the weight distribution of C A . For the special cases (a, b) = (1, 0) and (a, b) = (1, 1), using Lemmas 1 and 2, Wang et al [9] [10] obtained S(1, d) and S(1, 1+d) by tedious computation according to the value of d ∈ F * q , and they also remark in [10] that for any (a, b) = (1, b), b ∈ F q , their method is also effective. However, such computation method is difficult and complicated to be carried out to obtain S(a, b + d) for any pair (a, b) ∈ F 2 q and any d ∈ F * q . To overcome this difficulty, our technique is to use the following basic observations. Lemma 3. For any integer k and a ∈ F q , it holds that S(α k a) = S(a).
Proof. For any integer k, since α has order r m , it follows from (3) that Proof. For b = 0, the result is by (2). For b = 0, assume b = γ −k for some integer k, then c = ab − q−1 r m = aα k , and thus S(c) = S(a) by Lemma 3, then the result follows by Lemma 2.  For any (a, b) ∈ F 2 q with a = 0, it can be checked that the corresponding C A is a constant-weight code whose weight distribution is clear. We wonder what the weight distribution of C A is for any (a, b) ∈ F * q × F q , and we divide the analysis into two cases.
In this case, our main result is ] binary code with weight distribution described in Table 1.
Proof. Since the length of the code C A is equal to n 0 − 1, we get by substituting b = 0 into (6) that 4r m S(a). Define 4r m S(a), and assume the number of codewords with weight w 1 and w 2 is B 1 and B 2 , respectively. It suffices to compute B 1 and B 2 in order to get the weight distribution of Since the minimum distance of the dual code C ⊥ A of C A is at least 3, it follows from the first two Pless Power Moments [6, p.260] that the following system equations hold Solving this system of equations yields the weight distribution in Table 1.
The following examples show that many of them are optimal.
In this case, our main result is Theorem 10. Assume r m ≥ 5 and let c = ab − q−1 r m . Then, the code C A is a [ 2r m S(a), r m−1 (r − 1)] binary code with weight distribution described in Table 2.
Proof. As in the statement at the beginning of this section, the length of C A should be equal to n 0 − 1. According to (6), we get According to (7) and Lemma 4, each nonzero codeword c d ∈ C A with d ∈ F * q has Hamming weight . S(a, 0)) . Define Then, w 1 , w 2 and w 3 are all the possible weights of the code C A . Assume the number of codewords with weight w 1 , w 2 and w 3 is B 1 , B 2 and B 3 , respectively. It suffices to compute B 1 , B 2 and B 3 in order to get the weight distribution of C A . As in the proof of Theorem 5, since wt(c d ) > 0 for each nonzero codeword c d with d ∈ F * q by virtue of r m ≥ 5, the dimension of the code C A is φ(r m ) = r m−1 (r − 1). The same arguments as in the proof of Theorem 5 lead to the first three Pless Power Moments [6, p.260] equations 2r m S(a) 2 φ(r m )−1 2r m S(a) 2 φ(r m )−2 .
Solving this system of equations yields the weight distribution in Table 2.
Remark 11. The weight distribution of the code constructed in [10] may be considered as a special case of Theorem 10 with a = 1. Note that there exist two coinciding weights in Theorem 10 when r m = 5 and S(a) = 1 or r m = 9 and S(a) = 1, the three-weight code in Theorem 10 is in fact two-weight in the above two special cases.

4.
The dual code C ⊥ A of C A In Section 3, we showed that for any pair (a, b) ∈ F * q ×F q , the corresponding code C A is two-weight or three-weight. In this section, we will give two results about the dual of C A . One contribution is that we will show all the binary codes C ⊥ A have minimum distance 3. The other contribution is by using Lemma 4 to determine some subclasses of C ⊥ A which are optimal. Due to the Sphere Packing Bound [6, Theorem 1.12.1], the minimum weight of the dual C ⊥ A is at most 4. Note that the minimum weight of C ⊥ A is at least equal to 3, thus, all the binary codes C ⊥ A are optimal or almost optimal. In fact, we will show in this section that all the binary codes C ⊥ A have minimum distance 3, which has already been set up for C ⊥ A in [9] [10] with (a, b) = (1, 0) and (a, b) = (1, 1). Note that when (a, b) = (1, 0), the minimum distance of C ⊥ A being equal to 3 may be set up by using the properties of subfields of F q [9].
For (a, b) = (1, 1), the codeword length of C A is greater than q 2 by Theorem 10, and by using such a fact and the Pigeonhole principle, it was shown in [10] that the corresponding binary code C ⊥ A has minimum distance 3. The Pigeonhole principle, however, can no longer apply to other values taken by (a, b). For, the codeword length of C A , which by Theorems 5 and 10 is determined by the values of (a, b), may not be greater than q 2 . We thus have to find a new general proving method to obtain that any binary code C ⊥ A corresponding to any value of (a, b) (a ∈ F * q , b ∈ F q ) has minimum distance 3.
To this end, we first need a lemma. Recall that for any (a, b) ∈ F * q × F q , the defining set A is defined as Lemma 13. If r m ≥ 9, then for any (a, b) ∈ F * q × F q , A 1 = ∅. Proof. It suffices to show the size |A 1 | of A 1 satisfies |A 1 | > 0. We have Since S(a) ranges over r m − 4j, j = 1, 2, · · · , φ(r m )/2, when a ∈ F * q by Lemma 1, we obtain |A 1 | > 0 by Lemma 4 and the assumption r m ≥ 9.
Theorem 14. Assume r m ≥ 9. Then, each dual code C ⊥ A is a binary code with minimum distance 3.
Since F 2 t and {y : y ∈ F q , Tr(bx 0 y) = 0} can be considered as t-dimensional and at least (φ(r m ) − 1)-dimensional subspaces of F q over F 2 , respectively, it follows that F 2 t ∩ {y : y ∈ F q , Tr(bx 0 y) = 0} is also a subspace of F q over F 2 and dim(F 2 t ∩ {y : y ∈ F q , Tr(bx 0 y) = 0}) ≥ t − 1.
This and the assumption r m ≥ 9 yield that there exist two distinct elements y 1 ∈ S and y 2 ∈ S such that y 1 + y 2 ∈ S. Then, it holds that x 0 y 1 ∈ A 1 x 0 y 2 ∈ A 1 and x 0 y 1 + x 0 y 2 = x 0 (y 1 + y 2 ) ∈ A 1 . Equivalently, the dual code C ⊥ A has minimum distance 3.
Like the code C A , we state that many codes among C ⊥ A are optimal, as the following theorem says.
Theorem 15. Assume r m ≥ 9. Then, i) For any (a, b) ∈ F * q × F q with b = 0, the dual code C ⊥ A is optimal provided S(a) > 0.
ii) For any (a, b) ∈ F * q × F q with b = 0, the dual code C ⊥ A is optimal provided wt(c (0) ) is even.
Proof. i) Assume that the dual code C ⊥ A with parameters [n, n − φ(r m ), 3] is not optimal, where n = q−1 2 + q−1 2r m S(a). Then, there exists an [n, n − φ(r m ), 4] code. Let k be the maximum dimension among all the binary codes with length n and minimum distance at least 4. Then, k ≥ n − φ(r m ), and by [6, Theorem 2.1.2], k should also be the maximum dimension among all the binary codes with length n − 1 and minimum distance at least 3. Then, by the Sphere Packing Bound [6, Theorem 1.12.1], we have Thus, , which is nonsense when S(a) > 0. Thus, C ⊥ A is optimal.
ii) Note that in this case 2r m S(a) since wt(c (0) ) is even. Similarly to the proof as in i), if the code C ⊥ A is not optimal, then we get q 2 ≥ n.

The generalized Hamming weight of C A
In this section, we will study the support weight of the subcodes of C A . Our aim along this direction is to determine the generalized Hamming weight (GHW) of C A in certain cases by using Lemma 4.
Let C be a k-dimensional linear code. Then, the support of a subcode D is defined as the set of the coordinate positions where not all the codewords of D are zeroes, and the size of the support of D, denoted by w(D), is called the support weight of D.
The GHW of the code C is defined as the ordered sequence The GHW of a linear code was introduced by Wei [11], and it is useful in the wire-tap channel II with the coset coding scheme [11] and the analysis of the trellis complexity of a code [5]. Determining the GHW of a linear code is an interesting research problem [12].
Since the map from an element d ∈ F q to the codeword of C A defined by (5) is one-to-one on condition r m ≥ 9, we may identify the subcode of C A with the subspace of F q over F 2 . In the following text, we always assume r m ≥ 9 and identify a θ-dimensional subcode of C A with a θ-dimensional subspace of F q over F 2 .
We first obtain a formula describing the support weight of a θ-dimensional subcode V θ of C A , and then use this formula to determine the GHW of C A in certain cases.
Assume d i , 1 ≤ i ≤ θ, are basis elements of V θ (considered as a subspace of F q ) over F 2 , and Define Then, Thus, Formula (10) may be used to determine the GHW of the code C A in certain cases. We state our results according to whether b = 0 or b = 0 in the pair (a, b) ∈ F * q × F q .
Proof. If (a, b) = (a, 0), then for any θ-dimensional subspace V θ , it follows from (10) and Lemma 4 that S(a, d) To proceed the proof, it suffices to find a θ-dimensional subspace V θ ⊂ F q over F 2 such that w(V θ ) achieves the lower bound in (11).
For the general pair (a, b) with b = 0, the result is a little more complicated, and our main result is

Conclusion
In this paper, we obtained many classes of two-weight and three-weight codes by generalizing the constructing method introduced by Wang et al. The weight distributions of these two-weight and three-weight codes were completely determined, and the minimum distance of the duals of these codes was determined. We also showed that some subclasses of the duals of these codes were optimal. Furthermore, some parameters of the generalized Hamming weight of these codes were calculated in certain cases. We remarked that these two-weight and three-weight codes can be employed in secret sharing schemes using the framework in [14].