1 Introduction

Self-dual cyclic and negacyclic codes over finite fields have been extensively studied for both theoretical and practical reasons. Codes over finite rings have been of interest since it was proven that some binary non-linear codes such as the Kerdock, Preparata, and Goethal codes are the Gray images of linear codes over \({\mathbb {Z}}_4\) (see [9]). Cyclic codes, negacyclic codes and their generalizations have extensively been studied over \({\mathbb {Z}}_{p^r}\), Galois rings, with \(u^2=0\) and finite chain rings (see [1,2,3,4,5,6,7,8, 10, 11, 13,14,15,16] and references therein).

Recently, a lot attention has been paid to families of negacyclic and self-dual codes over , and there is a significant progress on these topics (see [3, 6,7,8, 14]). In [3], characterization and presentation of negacyclic codes of length \(p^s\) over have been established. Later, the algebraic structure of negacyclic codes of lengths \(2p^s\) and \(4p^s\) over the ring  has been studied in [6,7,8, 14]. Subsequently, properties of Euclidean duals of negacyclic codes and Euclidean self-dual negacyclic codes of lengths \(2p^s\) and \(4p^s\) over have been studied in [8, 14] and [6, 7], respectively. To the best of our knowledge, a complete characterization and enumeration of self-dual negacyclic codes of length \(p^s\) have not been explicitly given so far.

Using a method which is a modification of the one in [13], the algebraic structure and number of cyclic codes of length \(p^s\) over have been presented in [2]. In loc. cit., a complete characterization and enumeration of self-dual cyclic codes of length \(p^s\) over have been given under both the Euclidean and Hermitian inner products.

In this paper, we focus on negacyclic codes of length \(p^s\) over which makes sense only in the case where p is an odd prime and k is a positive integer. Throughout, assume that p is an odd prime and k is a positive integer. It is not difficult to verify that the map

defined by

is a ring isomorphism. Hence, the results on cyclic codes and self-dual cyclic codes of length \({p^s}\) over in [2] can be carried over to negacyclic codes and self-dual negacyclic codes of length \({p^s}\) over . Here, an alternative and direct method to study negacyclic codes and self-dual negacyclic codes of length \({p^s}\) over is given. Characterization and enumeration of negacyclic codes of length \({p^s}\) over are given by extending the techniques used in [2, 10, 12, 13]. Furthermore, characterization of self-dual negacyclic codes of length \({p^s}\) over  is established under both the Euclidean and Hermitian inner products. Based on this characterization, enumeration of such self-dual codes is provided as well.

The paper is organized as follows. In Sect. 2, some basic results on the ring are recalled. The characterization and enumeration of negacyclic codes of length \({p^s}\) over are provided in Sect. 3. In Sect. 4, the characterization and enumeration of self-dual negacyclic codes of length \({p^s}\) over are discussed.

2 Preliminaries

In this section, some definitions and basic properties of negacyclic codes over are recalled. For a prime p and positive integer k, denote by the finite field of order \({p^k}\). The set forms a commutative chain ring with identity, where addition and multiplication are defined as in the usual polynomial ring over with indeterminate u together with the condition . In the case where k is even, the map defined by

(1)

for all is a ring automorphism. For more details concerning properties of , we refer the reader to [3].

A linear code of length n over is defined to be an -submodule of the -module .

The Euclidean inner product on is defined by

for all and in . In addition, if k is even, the Hermitian inner product on is defined to be

for all and in . The Euclidean dual of a linear code C of length n over is defined to be

Similarly, if k is even, the Hermitian dual of C is defined as

A linear code C is said to be Euclidean self-dual (resp., Hermitian self-dual) if  (resp., ).

In the case where p is odd, \({-1\ne 1}\) in . Then we have the following concepts. A linear code C of length n over is called a negacyclic code if C is invariant under the negacyclic shift, i.e., for all . It is well known that there exists a one-to-one correspondence between the negacyclic codes of length n over  and the ideals in the quotient ring . Precisely, a negacyclic code C of length n can be represented by the ideal

in .

Here, we focus on negacyclic and self-dual negacyclic codes over . For convenience, denote by and the number of negacyclic codes, the number of Euclidean self-dual negacyclic codes, and the number of Hermitian self-dual negacyclic codes of length n over , respectively.

3 Negacyclic codes of length \({p^s}\) over

In this section, the characterization and enumeration of negacyclic codes of length \({p^s}\) over are given. By extending techniques used for cyclic codes of length \({p^s}\) over in [2], the algebraic structure and presentation of negacyclic codes of length \({p^s}\) over can be derived in terms of ideals in . Since the proofs are quite straightforwardly extended from [2], they will be omitted.

First, we note that the map defined by

$$\begin{aligned} \mu (f(x))= f(x) \;\; (\text {mod} \ u) \end{aligned}$$

is a surjective ring homomorphism.

For each negacyclic code C in and \({i\in \{0,1\}}\), let

For each \({i \in \{0,1\}}\), \({{\mathrm{Tor}}_i(C)}\) is called the ith torsion code of C. The codes \({{\mathrm{Tor}}_0({C})=\mu (C)}\) and \({{\mathrm{Tor}}_1(C)}\) are sometimes called the residue and torsion codes of C, respectively. It is not difficult to see that for each , \({c(x) \in {\mathrm{Tor}}_i(C)}\) if and only if for some . Consequently, \({{\mathrm{Tor}}_0(C)\subseteq {\mathrm{Tor}}_1(C)}\) are ideals in , i.e., they are negacyclic codes of length \({p^s}\) over . We note that every ideal in is of the form for some \({0\leqslant i\leqslant p^s}\) and its -dimension is \({p^{s-i}}\).

Proposition 3.1

([2, Proposition 5]) Let C be an ideal in  and let \({i\in \{0,1\}}\). Then the following statements hold:

  1. (i)

    \({{\mathrm{Tor}}_i(C)}\) is an ideal of  and \({{\mathrm{Tor}}_i(C)=\langle (x+1)^{T_i} \rangle }\) for some \({0\leqslant T_i \leqslant p^s}\).

  2. (ii)

    If \({{\mathrm{Tor}}_i(C)=\langle (x+1)^{T_i} \rangle }\), then \({|{\mathrm{Tor}}_i (C) |= (p^k)^{p^s-T_i}}\).

  3. (iii)

    .

With the notations given in Proposition 3.1, for each \({i\in \{0,1\}}\), is called the ith-torsional degree of C. Since \({{\mathrm{Tor}}_0(C)\subseteq {\mathrm{Tor}}_1(C)}\), we have \(0\leqslant T_1(C)\leqslant T_0(C)\leqslant p^s\). Moreover, if \({u(x+1)^t \in C}\), then \({t\geqslant T_1(C)}\).

Next, we focus on negacyclic codes of length \({p^s}\) over , or equivalently, ideals in .

Theorem 3.2

([2, Theorem 8]) Let C be an ideal in , , and . Then

$$\begin{aligned} C=\langle f_{0}(x),f_{1}(x)\rangle , \end{aligned}$$

where

and

with is either zero or a unit with . Moreover, \({(f_0(x),f_1(x))}\) is unique in the sense that if there exists a pair \({(g_0(x),g_1(x))}\) of polynomials satisfying the above conditions, then \({f_0(x)=g_0(x)}\) and \({f_1(x)=g_1(x)}\).

For each ideal C in , denote by the unique representation of the ideal C obtained in Theorem 3.2.

In order to determine the number of ideals in , the definition and some properties of the annihilator of an ideal in are revisited. For an ideal C in , the annihilator of C is defined to be . The following properties can be derived easily (cf. results for in [10, Theorems 12–13]).

Theorem 3.3

Let C be an ideal of . Then the following statements hold:

  1. (i)

    is an ideal of .

  2. (ii)

    If \({|C|=(p^k)^d}\), then .

  3. (iii)

    .

Theorem 3.4

Let \({{\mathscr {I}}}\) denote the set of ideals of , and let \({{\mathscr {A}}=\{ C\in {\mathscr {I}}: T_0(C)+T_1(C)\leqslant p^s \}}\) and \({{\mathscr {A}}'=\{ C\in {\mathscr {I}}: T_0(C)+T_1(C)\geqslant p^s \}}\). Then the map \({\phi :{\mathscr {A}}\rightarrow {\mathscr {A}}'}\) defined by is a bijection.

In view of Theorem 3.4, it suffices to focus on the ideals in \({{\mathscr {A}}}\). For each in \({{\mathscr {A}}}\), if \({f_0(x)=0}\), then \({T_0(C)=p^s}\) and \({T_1(C)=0}\). Hence, the only ideal in \({{\mathscr {A}}}\) with \({f_0(x)=0}\) is of the form . Under the assumption that \({f_0(x)\ne 0}\), the following two results can be obtained (cf. [10, Theorems 14–15] for cyclic codes).

Theorem 3.5

Let be the representation of an ideal in . Then it is a representation of an ideal in \({{\mathscr {A}}}\) if and only if \({i_0,i_1,t}\) are integers and such that \({0\leqslant i_0<p^s}\), \({t\geqslant 0,}\) , and h(x) is either zero or a unit in .

Since every polynomial \({\sum _{i=0}^{m}a_i(x+1)^i}\) in is either 0 or \({(x+1)^t h(x)}\), where h(x) is a unit in and , Theorem 3.5 can be rewritten as follows.

Theorem 3.6

The expression represents an ideal in \({{\mathscr {A}}}\) if and only if \({i_0}\) and \({i_1}\) are integers such that \({0\leqslant i_0<p^s}\), , \({i_0+i_1\leqslant p^s}\), and for all \({0\leqslant j<i_1}\).

Proposition 3.7

Let \({0\leqslant d\leqslant p^s}\). Then the number of distinct ideals in with \({T_0+T_1=d}\) is

where .

Proof

Let \({T_1 = i_1}\) and \({i_0 :=T_0=d-T_1}\) be fixed.

Case 1: \({d< p^s}\). Then \({i_0\leqslant i_0+i_1=T_0+T_1=d< p^s}\). By Theorem 3.6, it follows that . Then the choice for is \({(p^k)^{i_1}}\). By Theorem 3.6 again, we also have . Since \({T_0+T_1=d}\), we obtain that \({T_1\leqslant \lfloor {d}/{2} \rfloor \leqslant T_0}\), and hence, . Now, vary \({T_1}\) from 0 to K, we obtain that there are \({1+p^k+\cdots +(p^k)^K=({p^{k(K+1)}-1})/({p^k-1})}\) ideals with \({T_0+T_1=d}\).

Case 2: \({d=p^s}\). If \({i_0=p^s}\), then the only ideal with \({T_0+T_1=p^s}\) is the ideal represented by . If \({i_0<p^s}\), then we have \({p^k+(p^k)^2+\cdots +(p^k)^K}\) ideals by arguments similar to those in Case 1. \(\square \)

For a negacyclic code C in \({{\mathscr {A}}}\), we have whenever \({T_0(C)+T_1(C)<p^s}\). In the case where \({T_0(C)+T_1(C)=p^s}\), by Theorem 3.5, the annihilator of the negecyclic code is of the form . Since p is odd, then occurs only in the case \({h(x)=0}\). By Proposition 3.7 and the bijection given in Theorem 3.4, we have

Corollary 3.8

The number of negacyclic codes of length \({p^s}\) over is

Proof

From Theorem 3.4, the number of negacyclic codes of length \({p^s}\) over is \({|{\mathscr {A}}\cup {\mathscr {A}}'|=|{\mathscr {A}}|+|{\mathscr {A}}'|-|{\mathscr {A}}\cap {\mathscr {A}}'|}\). The desired result follows immediately from the discussion above. \(\square \)

4 Self-dual negacyclic codes of length \({p^s}\) over

In this section, the characterization and enumeration of self-dual negacyclic codes of length \({p^s}\) over are established under both the Euclidean and Hermitian inner products.

4.1 Euclidean self-dual negacyclic codes of length \({p^s}\) over

We define a conjugation on to be the map that fixes and sends \({x^l}\) to \({x^{-l}}\) for all \({l\in {\mathbb {Z}}_{p^s}}\). For each subset A of the ring , we denote by \({{\overline{A}}}\) the set of polynomials \({\overline{f(x)}}\) for all f(x) in A. The following result can be derived similarly to [10, Theorem 18].

Theorem 4.1

Let C be an ideal in . Then .

Theorem 4.2

The Euclidean dual \({C^{\bot _{\mathrm {E}}}}\) of the ideal given in Theorem 3.6 is of the form

Proof

From Theorem 3.6, it can be concluded that

By Theorem 4.1, it follows that . Hence, \({C^{\bot _{\mathrm {E}}}}\) contains the elements \({u(x+1)^{p^s-i_{0}}}\) and

By writing \({x=(x+1)-1}\) and applying the Binomial Theorem, it can be concluded that \({C^{\bot _{\mathrm {E}}}}\) contains an element of the form

Hence,

Comparing the cardinalities, the two sets are equal. Updating the indices, it follows that

as desired. \(\square \)

We note that, if \({i_1=0}\), then \({C=\langle u \rangle }\) is the only Euclidean self-dual ideal.

Assume that C is Euclidean self-dual. Then \({C=C^{\bot _{\mathrm{E}}}}\) which implies that \({| C |=(p^k)^{p^s}}\) and \({i_0+i_1=p^s}\).

Assume that \({i_1\geqslant 1}\). Since

is Euclidean self-dual in , it follows that \({p^s=i_0+i_1}\) and

(2)

in \({{\mathbb {F}}_{\! p^k}}\) for all \({0\leqslant t\leqslant i_i-1}\) by Theorem 4.2.

Let be an -matrix defined by

(3)

It is easily seen that the \({i_1}\) equations from (2) are equivalent to the matrix equation

(4)

where \({{\varvec{h}}=(h_0,h_1,\ldots ,h_{i_1-1})^{\mathrm{T}}}\) and \({{\varvec{0}}=(0,0,\ldots ,0)^{\mathrm{T}}}\).

Hence, the ideal C in is Euclidean self-dual if and only if \({p^s=i_0+i_1}\) and \({h_0,h_1,\ldots ,h_{i_1-1}}\) satisfy (4). Since \({h_0=h_1=\cdots =h_{i_1-1}=0}\) is a solution to (4), the corresponding ideal is a Euclidean self-dual negacyclic code in . Hence, for a fixed first torsion degree \({1\leqslant i_1\leqslant p^s}\), a Euclidean self-dual ideal in always exists. By solving (4), all Euclidean self-dual ideals in can be constructed.

In order to determine the number of solutions to (4), or equivalently, the nullity of , we recall the -matrix over defined in [13] as

The nullity of can be determined in terms of as in the following theorem.

Theorem 4.3

Let \({i_1}\) be a positive integer such that \({i_1\leqslant p^s}\). Then the nullity of is .

Proof

First, we show that and have the same nullity. We consider the following two cases.

Case 1: \({i_1}\) is odd. Let be an -matrix over . It is not difficult to see that A is invertible and .

Case 2: \({i_1}\) is even. Let be an \({i_1{\times } i_1}\) matrix over . It is not difficult to see that A is invertible and .

From the two cases, the nullity of and the nullity of are equal. From [13, Proposition 3.3], the nullity of is . Hence, the nullity of is as desired. \(\square \)

Proposition 4.4

Let \({i_1>0}\) and let \({\kappa }\) be the nullity of over . Then the number of Euclidean self-dual negacyclic codes of length \({p^s}\) over with first torsional degree \({i_1}\) is \({(p^k)^\kappa }\).

From Theorem 3.6, we have \({0\leqslant i_1\leqslant \lfloor {p^s}/{2}\rfloor }\) since \({i_0+i_1=p^s}\).

Corollary 4.5

Let k and s be positive integers and let p an odd prime. Then the number of Euclidean self-dual negacyclic codes of length \({p^s}\) over is

Proof

From Theorem 4.3 and Proposition  4.4, the number of Euclidean self-dual negacyclic codes of length \({p^s}\) over is . Note that \({p^s \equiv 3 \ \mathrm{mod }\, 4}\) (resp., \({p^s \equiv 1 \ \mathrm{mod }\, 4}\)) if and only if \({({p^{s}+1})/{4}}\) (resp., \({({p^{s}-1})/{4}}\)) is an integer. Hence, the results follow from a geometric sum. \(\square \)

4.2 Hermitian self-dual negacyclic codes of length \({p^s}\) over

Under the assumption that k is even, characterization and enumeration Hermitian self-dual negacyclic codes of length \({p^s}\) over are given. For a subset A of , let

where is the automorphism defined in (1).

Based on the unique presentation of a negacyclic code given in Theorem 3.6, its Hermitian dual can be determined using Theorem 4.2 and the fact that \({C^{\bot _{\mathrm {H}}}=\widetilde{C^{\perp _{\mathrm{E}}}}}\).

Theorem 4.6

The Hermitian dual \({C^{\bot _{\mathrm {H}}}}\) of the ideal given in Theorem 3.6 has the representation

If \({i_1=0}\), then it is not difficult to see that the ideal generated by u is the only Hermitian self-dual negacyclic code of length \({p^s}\) over .

Assume that C is Hermitian self-dual. Then \({C=C^{\bot _{\mathrm{H}}}}\) implies that \({| C |=(p^k)^{p^s}}\) and \({i_0+i_1=p^s}\).

Assume that \({i_1\geqslant 1}\). Then, by Theorems 3.6 and  4.6, we have

for all \({0\leqslant t\leqslant i_1-1.}\)

From the \({i_1}\) equations above and the definition of , we have

(5)

where \({{\varvec{x}}=(x_1,x_2,\ldots ,x_{i_1})^{\mathrm{T}}}\), and . It can be concluded that an ideal C in is Hermitian self-dual if and only if \({p^s=i_0+i_1}\) and \({h_0,h_1,\ldots ,h_{i_1-1}}\) satisfy (5). Since \({h_0=h_1=\dots =h_{i_1-1}=0}\) is a solution to (5), the corresponding ideal is a Hermitian self-dual negacyclic code in . Hence, for a fixed first torsion degree \({1\leqslant i_1\leqslant p^s}\), a Hermitian self-dual negacyclic code in always exists. By solving (5), all Hermitian self-dual negacyclic codes in can be constructed.

In order to determine the number of solutions to (5), we shall need some properties of . For integers i and j such that \({1\leqslant i, j \leqslant i_1}\), let \({v_{ij}}\) denote the entry in the ith row and the jth column of the matrix . For an integer l, \({1 \leqslant l \leqslant j< i\leqslant i_1}\), we have

$$\begin{aligned} {v_{ij}=(-1)^{i_0-i+1}\left( \begin{array}{c}i_0-j+1\\ i-j \end{array}\right) } \end{aligned}$$

and

$$\begin{aligned} v_{ij}v_{jl}=(-1)^{i_0-i+1}\left( \begin{array}{c}i-l\\ j-l \end{array}\right) v_{il} . \end{aligned}$$

The following two maps in [10] are key to determine the number of solutions to (5) in :

  • The map is defined by for all .

  • The trace map is defined by for all .

From [10], we have that \({{\Psi }}\) and \({{\mathrm{Tr}}}\) are -linear.

Lemma 4.7

([10, Lemma 3.2]) Let \({{\mathrm{Tr}}}\) and \({{\Psi }}\) be defined as above. Then the following statements hold:

  • For each , \({{\Psi } (\alpha )=0}\) if and only if .

  • .

  • For each , \({| {\Psi } ^{-1}(a)|=p^{k/2}}\).

  • For each , \({|{\mathrm{Tr}}^{-1}(a)|=p^{k/2}}\).

Similarly to [10, Proposition 3.3], we have

Proposition 4.8

Let k and s be positive integers such that k is even, and let p be an odd prime. Let \({i_1}\) be a positive integer such that \({i_1\leqslant \lfloor {p^{s}}/{2}\rfloor }\). Then the number of solutions to (5) in is \({p^{ki_1/2}}\).

Proof

From (3), the diagonal of has two different presentations depending on the parity of \({i_1}\). Hence, the proof consists of two cases.

Case 1: \({i_1}\) is odd. Then \({i_1=2\mu +1}\) for some non-negative integer \({\mu }\). From (3), the matrix can be written as

where \({*}\) denotes an entry of the matrix  as defined in (3). It is easily seen that

$$\begin{aligned} {\mathrm{Tr}}(x_1)&=0,\end{aligned}$$
(6)
$$\begin{aligned} {\Psi }(x_{2I})&=-\sum _{j=1}^{2i-1}v_{2i,j}x_{j}, \end{aligned}$$
(7)
$$\begin{aligned} {\mathrm{Tr}}(x_{2i+1})&=-\sum _{j=1}^{2i}v_{2i+1,j}x_{j} \end{aligned}$$
(8)

for all integers \({1\leqslant i \leqslant \mu }\). We observe that (5) has a solution if and only if the right-hand sides of (6) and (8) are in and the right-hand side of (7) is in . In this case, it can be deduced that

for all integers \({1\leqslant i \leqslant \mu }\). Equivalently, the number of solutions to (5) is \({p^{ki_1/2}}\) by Lemma 4.7.

To reason the discussion above, by Lemma 4.7, it suffices to show that the images under \({{\Psi }}\) of the right-hand sides of (6) and (8) are 0 and the image under the trace map \({{\mathrm{Tr}}}\) of the right-hand side of (7) is 0. We note that the image under \({{\Psi }}\) of the right-hand sides of (6) is 0.

Let \({1\leqslant i \leqslant \mu }\) be an integer. Using calculation similar to the one in [10, Equation (3.11)], it follows that

Using calculation similar to the one in [10, Equation (3.12)], it follows that

Case 2: \({i_1}\) is even. Then \({i_1=2\mu }\) for some positive integer \({\mu }\). From (3), the matrix can be written as

where \({*}\) denotes an entry of the matrix  defined in (3). We see that

$$\begin{aligned} {\Psi } (x_{2i-1})&=-\sum _{j=1}^{2i-2}v_{2i-1,j}x_{j} , \end{aligned}$$
(9)
$$\begin{aligned} {\mathrm{Tr}}(x_{2i})&=-\sum _{j=1}^{2i-1}v_{2i,j}x_{j} \end{aligned}$$
(10)

for all integers \({1\leqslant i \leqslant \mu }\).

We observe that (5) has a solution if and only if the right-hand side of (9) is in and the right-hand side of (10) is in . In this case, the number of solutions to (5) is \({p^{ki_1/2}}\) by Lemma 4.7. By Lemma 4.7 again, it is sufficient to show that the image under the trace map \({{\mathrm{Tr}}}\) of right-hand side of (9) and the image under the \({{\Psi }}\) of right-hand side of (10) are 0. By using calculation similar to the one in Case 1, the proof is completed. \(\square \)

Corollary 4.9

Let k and s be positive integers such that k is even, and let p be an odd prime. Then the number of Hermitian self-dual negacyclic codes of length \({p^s}\) over is