1 Introduction

For an odd prime number p and a positive integer e, let \( {\mathbb {F}}_{q} \) be the finite field with \( q=p^{e} \) elements and \({\mathbb {F}}_{q}^{*}\) be its multiplicative group.

An [nkd] p-ary linear code C is a k-dimensional subspace of \( {\mathbb {F}}_{p}^{n} \) with minimum (Hamming) distance d. For \(0\le i \le n\), 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_1z+ A_2z^2 + \cdots + A_nz^n \). The sequence \((1,A_{1},\ldots ,A_{n})\) is called the weight distribution of C. A code C is said to be a t-weight code if the number of nonzero \(A_i\) in the sequence \((A_{1},\ldots ,A_{n})\) is equal to t. The weight distribution can give the minimum distance of the code. Moreover, it allows the computation of the error probability of error detection and correction [23].

The weight distribution of a linear code is an important research topic in coding theory. Some researchers devoted themselves to calculating the weight distributions of linear codes [8, 14, 15, 37, 49]. Linear codes with a few weights can be applied to secret sharing [50], association schemes [5], combinatorial designs [38], authentication codes [13] and strongly regular graphs [6]. There are some studies about linear codes with a few weights, for which the reader is referred to [22, 24, 26, 33, 34, 36].

The weight hierarchy of a linear code is another important research topic in coding theory [4, 7, 16, 17, 20, 45, 46, 48]. We recall the definition of the generalized Hamming weights of linear codes [45]. For an [nkd] code C and \(1\le r\le k\), denote by \( [C,r]_{p} \) the set of all its \({\mathbb {F}}_{p}\)-vector subspaces with dimension r. For \( H \in [C,r]_{p}\), define \( \text {Supp}(H)=\bigcup _{c\in H}\text {Supp}(c)\), where \(\text {Supp}(c)\) is the set of coordinates where c is nonzero, that is,

$$\begin{aligned} \text {Supp}(H)=\Big \{i:1\le i\le n, c_i\ne 0 \ \ \text {for some } c=(c_{1}, c_{2}, \ldots , c_{n})\in H \Big \}. \end{aligned}$$

The r-th generalized Hamming weight (GHW) \( d_{r}(C)\) of C is defined to be

$$\begin{aligned} d_{r}(C)=\min \Big \{|\text {Supp}(H)|:H\in [C,r]_{p}\Big \}, \ 1\le r\le k. \end{aligned}$$

It is easy to see that \( d_{1}(C)\) is the minimum distance d. The weight hierarchy of C is defined as the sequence \( \big (d_{1}(C),d_{2}(C),\ldots ,d_{k}(C)\big )\). For more details, one is referred to [18]. There are some results about the weight hierarchies of linear codes [3, 21, 27,28,29, 31, 35, 47].

Let \(\mathrm {Tr}\) denote the trace function from \({\mathbb {F}}_{q}\) onto \({\mathbb {F}}_{p}\) throughout this paper. For \( D= \Big \{d_{1},d_{2},\ldots ,d_{n}\Big \}\subseteq {\mathbb {F}}_{q}^{*}\), a p-ary linear code \(C_{D}\) of length n is defined by

$$\begin{aligned} C_{\mathrm {D}}=\Big \{\left( \mathrm {Tr}(xd_1), \mathrm {Tr}(xd_2),\ldots , \mathrm {Tr}(xd_{n})\right) :x\in {\mathbb {F}}_{q}\Big \}. \end{aligned}$$
(1)

Here D is called the defining set of \(C_{D}\) and \(C_D\) can be called a trace code. This construction technique is called the defining-set construction of linear codes, which was first proposed by Ding et al. [10]. The defining-set construction is generic in the sense that many classes of known codes can be produced by selecting some proper defining sets. It has attracted a lot of attention, and a huge amount of linear codes with good parameters have been obtained [9, 11, 12, 14, 44, 49, 52].

In recent years, Shi et al. [39,40,41,42,43] refined the technique of the study of trace codes by using ring extensions of a finite field coupled with a linear Gray map and obtained many families of p-ary codes with few weights over different finite rings. Most of their obtained codes are optimal and minimal codes, which can be applied to secret sharing schemes (SSS).

Li et al. [25] extended Ding’s defining-set construction as follows. Recall that the ordinary inner product of vectors \(\mathrm {x}=(x_1,x_2,\ldots ,x_s),\ \mathrm {y}=(y_1,y_2,\ldots ,y_s) \in {\mathbb {F}}_{q}^{s}\) is

$$\begin{aligned} \mathrm {x}\cdot \mathrm {y}=x_{1}y_{1}+x_{2}y_{2}+\cdots +x_{s}y_{s}. \end{aligned}$$

A p-ary linear code \( C_{\mathrm {D}} \) with length n can be defined by

$$\begin{aligned} C_{\mathrm {D}}=\Big \{\big ( \mathrm {Tr}(\mathrm {x}\cdot \mathrm {d}_1), \mathrm {Tr}(\mathrm {x}\cdot \mathrm {d}_2),\ldots , \mathrm {Tr}(\mathrm {x}\cdot \mathrm {d}_{n})\big ): \mathrm {x}\in {\mathbb {F}}_{q}^{s}\Big \}, \end{aligned}$$
(2)

where \( \mathrm {D}= \Big \{\mathrm {d}_{1},\mathrm {d}_{2},\ldots ,\mathrm {d}_{n}\Big \}\subseteq {\mathbb {F}}_{q}^{s}\backslash \big \{(0,0,\ldots ,0)\}\) is also called the defining set of \( C_{\mathrm {D}}\). Using this construction, some classes of linear codes with few weights have been constructed [2, 22, 26, 30, 31].

Tang et al. [44] constructed a p-ary linear code \(C_\mathrm {D}\) in (1) with at most five nonzero weights from inhomogeneous quadratic function and their defining set is \(\mathrm {D}=\Big \{x\in {\mathbb {F}}_{q}^{*}: f(x)-\mathrm {Tr}(\alpha x)=0\Big \}\), where \(\alpha \in {\mathbb {F}}_{q}^{*}\) and f(x) is a homogeneous quadratic function from \({\mathbb {F}}_{q}\) onto \({\mathbb {F}}_{p}\) defined by

$$\begin{aligned} f(x)=\sum _{i=0}^{e-1} \mathrm {Tr}(a_{i}x^{p^{i}+1}), \ a_{i}\in {\mathbb {F}}_{q}. \end{aligned}$$
(3)

In this paper, inspired by the works of [28, 44], we choose a defining set contained in \({\mathbb {F}}_{q}^{2} \) as follows. For \(\alpha \in {\mathbb {F}}_{q}^{*}\), set

$$\begin{aligned} \mathrm {D}=\mathrm {D}_{\alpha }=\Big \{(x,y)\in {\mathbb {F}}_{q}^{2}\setminus \{(0,0)\}: f(x)+\mathrm {Tr}(\alpha y)=0\Big \} =\Big \{\mathrm {d}_1, \ldots , \mathrm {d}_n\Big \}, \end{aligned}$$
(4)

where f(x) is defined in (3) and non-degenerate. So, the corresponding p-ary linear codes \(C_{\mathrm {D}}\) in (2) is

$$\begin{aligned} C_{\mathrm {D}}=\Big \{\big ( \mathrm {Tr}(\mathrm {x}\cdot \mathrm {d}_1), \mathrm {Tr}(\mathrm {x}\cdot \mathrm {d}_2),\ldots , \mathrm {Tr}(\mathrm {x}\cdot \mathrm {d}_{n})\big ): \mathrm {x}\in {\mathbb {F}}_{q}^{2}\Big \}. \end{aligned}$$
(5)

We mainly determine their weight distributions and weight hierarchies.

The remainder of this paper is organized as follows. Section 2 introduces some basic notation and results about quadratic forms. Section 3 presents the linear codes with three nonzero weights and determines their weight distributions and weight hierarchies. Section 4 summarizes this paper.

2 Preliminaries

In this section, we state some notation and basic facts on quadratic forms and f defined in (3). These results will be used in the rest of the paper.

2.1 Some notation fixed throughout this paper

For convenience, we fix the following notation. For basic results on cyclotomic field \( {\mathbb {Q}}(\zeta _{p}) \), one is referred to [19].

  • Let \(\mathrm {Tr}\) be the trace function from \({\mathbb {F}}_{q}\) to \({\mathbb {F}}_{p}\). Namely, for each \(x\in {\mathbb {F}}_{q}\),

    $$\begin{aligned} \mathrm {Tr}(x)=x+x^{p}+ \cdots +x^{p^{e-1}}. \end{aligned}$$
  • \(p^{*}=(-1)^{\frac{p-1}{2}}p\).

  • \(\zeta _{p}=\exp (\frac{2\pi i}{p})\) is a primitive p-th root of unity.

  • \({\bar{\eta }}\) is the quadratic character of \({\mathbb {F}}_{p}^{*}\). It is extended by letting \({\bar{\eta }}(0)=0\).

  • Let \({\mathbb {Z}}\) be the rational integer ring and \({\mathbb {Q}}\) be the rational field. Let \({\mathbb {K}}\) be the cyclotomic field \({\mathbb {Q}}(\zeta _{p})\). The field extension \({\mathbb {K}}/{\mathbb {Q}}\) is Galois of degree \(p-1\). The Galois group \(\mathrm {Gal}({\mathbb {K}}/{\mathbb {Q}})=\Big \{\sigma _{z}: z\in ({\mathbb {Z}}/ p{\mathbb {Z}})^{*}\Big \}\), where the automorphism \(\sigma _{z}\) is defined by \(\sigma _{z}(\zeta _{p})=\zeta _{p}^{z}\).

  • \(\sigma _{z}(\sqrt{p^{*}})={\bar{\eta }}(z)\sqrt{p^{*}}\), for \(1\le z \le p-1\).

  • Let \(\Big \langle \alpha _{1},\alpha _{2},\ldots ,\alpha _{r}\Big \rangle \) denote a space spanned by \(\alpha _{1},\alpha _{2},\ldots ,\alpha _{r}\).

2.2 Quadratic form

Viewing \({\mathbb {F}}_{q}\) as an \({\mathbb {F}}_{p}\)-linear space and fixing \(\upsilon _{1},\upsilon _{2},\ldots ,\upsilon _{e} \in {\mathbb {F}}_{q} \) as its \({\mathbb {F}}_{p}\)-basis, then for any \(x=x_{1}\upsilon _{1}+x_{2}\upsilon _{2}+\cdots +x_{e}\upsilon _{e} \in {\mathbb {F}}_{q}\) with \(x_i\in {\mathbb {F}}_{p}, i=1,2,\ldots ,e\), there is an \({\mathbb {F}}_{p}\)-linear isomorphism \({\mathbb {F}}_{q}\simeq {\mathbb {F}}_{p}^e\) defined as:

$$\begin{aligned} x=x_{1}\upsilon _{1}+x_{2}\upsilon _{2}+\cdots +x_{e}\upsilon _{e} \mapsto X=(x_1,x_2,\ldots ,x_e), \end{aligned}$$

where \(X=(x_1,x_2,\ldots ,x_e)\) is called the coordinate vector of x under the basis \(v_1,v_2,\ldots ,v_e\) of \({\mathbb {F}}_{q}\).

A quadratic form g over \({\mathbb {F}}_{q}\) with values in \({\mathbb {F}}_{p}\) can be represented by

$$\begin{aligned} g(x)=g(X)=g(x_{1},x_{2},\ldots ,x_{e})&=\sum _{1\le i,j\le e}a_{ij}x_{i}x_{j}\\&=XAX^T, \end{aligned}$$

where \(A=(a_{ij})_{n\times n}, a_{ij}\in {\mathbb {F}}_{p}, a_{ij}=a_{ji}\) and \(X^T\) is the transposition of X. Denote by \(R_g=\text {Rank}\ A\) the rank of g, there exists an invertible matrix M over \({\mathbb {F}}_{p}\) such that

$$\begin{aligned} MAM^T=\text {diag}(\lambda _{1},\lambda _{2},\ldots ,\lambda _{R_{g}},0,\ldots ,0) \end{aligned}$$

is a diagonal matrix, where \(\lambda _{1},\lambda _{2},\ldots ,\lambda _{R_{g}}\in {\mathbb {F}}_{p}^{*}\). Let \(\varDelta _{g}=\lambda _{1}\lambda _{2}\cdots \lambda _{R_{g}}\), and \(\varDelta _{g}=1\) if \(R_{g}=0.\) We call \({\bar{\eta }}(\varDelta _{g})\) the sign \(\varepsilon _{g}\) of the quadratic form g. It is an invariant under nonsingular linear transformations in matrix.

Let

$$\begin{aligned} F(x,y)=\frac{1}{2}\big (g(x+y)-g(x)-g(y)\big ). \end{aligned}$$

For an r-dimensional subspace H of \({\mathbb {F}}_{q}\), its dual space \(H^{\perp _g}\) is defined by

$$\begin{aligned} H^{\perp _g}=\Big \{x\in {\mathbb {F}}_{q}:\ F(x,y)=0, \ \text{ for } \text{ any } \ y \in H\Big \}. \end{aligned}$$

Restricting the quadratic form g to H, it becomes a quadratic form denoted by \(g|_{H}\) over H in r variables. In this situation, we denote by \(R_{H}\) and \(\varepsilon _{H}\) the rank and sign of \(g|_{H}\), respectively.

In the following, we suppose \(R_{g}=e\), i.e., g is a non-degenerate quadratic form. For \(\beta \in {\mathbb {F}}_{p}\), set

$$\begin{aligned} {\overline{D}}_{\beta }=\Big \{x\in {\mathbb {F}}_{q}|g(x)=\beta \Big \}, \end{aligned}$$
(6)

we shall give some lemmas, which are essential to prove our main results.

Lemma 1

[28, Proposition 1] Let g be a non-degenerate quadratic form and H be an r-dimensional nonzero subspace of \({\mathbb {F}}_{q}\), then

$$\begin{aligned} |H\cap {\overline{D}}_{\beta }|=\left\{ \begin{array}{ll} p^{r-1}+v(\beta ){\overline{\eta }}((-1)^{\frac{R_{H}}{2}})\varepsilon _{H}p^{r-\frac{R_{H}+2}{2}}, &{}\text {if } \ R_{H}\equiv 0\pmod 2, \\ p^{r-1}+{\overline{\eta }}((-1)^{\frac{R_{H}-1}{2}}\beta )\varepsilon _{H}p^{r-\frac{R_{H}+1}{2}}, &{}\text {if } \ R_{H}\equiv 1\pmod 2, \end{array} \right. \end{aligned}$$

where \(v(\beta )=p-1\) if \(\beta =0\), otherwise \(v(\beta )=-1\).

Lemma 2

[28, Proposition 2] Let g be a non-degenerate quadratic form. For each \( r\ (0<2r < e)\), there exists an r-dimensional subspace \(H\subseteq {\mathbb {F}}_{p^{e}}(e>2)\) such that \(H\subseteq H^{\perp _g}\).

Lemma 3

[28, Proposition 3] Let g be a non-degenerate quadratic form and \( e=2s>2\). There exists an s-dimensional subspace \(H_{s}\subset {\mathbb {F}}_{p^{e}}\) such that \(H_{s}=H^{\perp _g}_{s}\) if and only if \(\varepsilon _{g}=(-1)^{\frac{e(p-1)}{4}}\).

Lemma 4

[28, Theorem 1] Let g be a non-degenerate quadratic form and \(\beta \) be a nonzero element in \({\mathbb {F}}_{p}\). If \(e(e > 2)\) is even, then for the linear codes \(C_{{\overline{D}}_{\beta }}\) in (1) with defining sets \({\overline{D}}_{\beta }\) defined in (6), we have

$$\begin{aligned} d_{r}(C_{{\overline{D}}_{\beta }})=\left\{ \begin{array}{ll} p^{e-1}-p^{e-r-1}-\Big ((-1)^{\frac{e(p-1)}{4}}\varepsilon _{g}+1\Big )p^{\frac{e-2}{2}}, &{} \text {if } \ 1\le r\le \frac{e}{2}, \\ p^{e-1}-2p^{e-r-1}-(-1)^{\frac{e(p-1)}{4}}\varepsilon _{g}p^{\frac{e-2}{2}}, &{} \text {if } \ \frac{e}{2}< r< e, \\ p^{e-1}-(-1)^{\frac{e(p-1)}{4}}\varepsilon _{g}p^{\frac{e-2}{2}}, &{} \text {if } \ r= e. \end{array} \right. \end{aligned}$$

Lemma 5

[28, Theorem 2] Let g be a non-degenerate quadratic form and \(\beta \) be a nonzero element in \({\mathbb {F}}_{p}\). If \({\bar{\eta }}(\beta )=(-1)^{\frac{(e-1)(p-1)}{4}}\varepsilon _{g}\) and \(e\ (e\ge 3)\) is odd, then for the linear codes \(C_{{\overline{D}}_{\beta }}\) in (1) with defining sets \({\overline{D}}_{\beta }\) defined in (6), we have

$$\begin{aligned} d_{r}(C_{{\overline{D}}_{\beta }})=\left\{ \begin{array}{ll} p^{e-1}-p^{e-r-1}, &{} \text {if } \ 1\le r< \frac{e}{2}, \\ p^{e-1}+p^{\frac{e-1}{2}}-2p^{e-r-1}, &{} \text {if } \ \frac{e}{2}< r< e, \\ p^{e-1}+p^{\frac{e-1}{2}}, &{} \text {if } \ r= e. \end{array} \right. \end{aligned}$$

In the following, we present some auxiliary results about f defined in (3), which will play important roles in settling the weight distributions and weight hierarchies. For more details, one is referred to [44].

For any \(x\in {\mathbb {F}}_{q}\), x can be uniquely expressed as \(x=x_{1}\upsilon _{1}+x_{2}\upsilon _{2}+\cdots +x_{e}\upsilon _{e}\) with \(x_i\in {\mathbb {F}}_{p}\). Hence, we have

$$\begin{aligned} f(x)&=\sum _{i=0}^{e-1} \mathrm {Tr}\big (a_{i}x^{p^{i}+1}\big )=\sum _{i=0}^{e-1} \mathrm {Tr}\left( a_{i}\left( \sum _{j=1}^{e}x_j\upsilon _j\right) ^{p^{i}+1}\right) \\&=\sum _{i=0}^{e-1} \mathrm {Tr}\left( a_{i}\left( \sum _{j=1}^{e}x_j\upsilon _j^{p^i}\right) \left( \sum _{k=1}^{e}x_k\upsilon _k\right) \right) \\&=\sum _{j=1}^{e}\sum _{k=1}^{e}\left( \sum _{i=0}^{e-1}\mathrm {Tr}\Big (a_iv_j^{p^i}v_k\Big )\right) x_jx_k=XBX^T, \end{aligned}$$

where \(X=(x_1,x_2,\ldots ,x_e)\) and \(B=\Big (\frac{1}{2}\sum _{i=0}^{e-1}\mathrm {Tr}\big (a_i(v_j^{p^i}v_k+v_jv_k^{p^i})\big )\Big )_{e\times e}\). Thus, f is a quadratic form and for any \(x,y\in {\mathbb {F}}_{q}\), we have

$$\begin{aligned} F(x,y)&=\frac{1}{2}\big (f(x+y)-f(x)-f(y)\big )=\frac{1}{2}\sum _{i=0}^{e-1}\mathrm {Tr} \Big (a_i(x^{p^i}y+xy^{p^i})\Big )\\&=\frac{1}{2}\sum _{i=0}^{e-1}\mathrm {Tr}\Big (a_ix^{p^i}y\Big )+\frac{1}{2}\sum _{i=0}^{e-1}\mathrm {Tr}\Big (\Big (a_{i}^{p^{-i}}x^{p^{-i}}y\Big )^{p^i}\Big )\\&=\frac{1}{2}\sum _{i=0}^{e-1}\mathrm {Tr}\Big (a_ix^{p^i}y\Big )+\frac{1}{2}\sum _{i=0}^{e-1}\mathrm {Tr}\Big (a_{i}^{p^{e-i}}x^{p^{e-i}}y\Big )\\&=\mathrm {Tr}\left( \left( a_0x+\frac{1}{2}\sum _{i=1}^{e-1}\Big (a_i+a_{e-i}^{p^i}\Big )x^{p^i}\right) y\right) \\&=\mathrm {Tr}\big (yL_{f}(x)\big ), \end{aligned}$$

where \(L_{f}\) is a linearized polynomial over \({\mathbb {F}}_q\) defined as

$$\begin{aligned} L_{f}(x)=a_0x+\frac{1}{2}\sum _{i=1}^{e-1}\big (a_i+a_{e-i}^{p^i}\big )x^{p^i}. \end{aligned}$$
(7)

Let \(\mathrm {Im}(L_{f})=\Big \{L_{f}(x):x\in {\mathbb {F}}_q\Big \},\ \mathrm {Ker}(L_{f})=\Big \{x\in {\mathbb {F}}_q: L_{f}(x)=0\Big \}\) denote the image and kernel of \(L_{f}\), respectively. Noticing that f(x) is non-degenerate, we have \(R_f = e, \mathrm {Ker}(L_{f}) = \{0\}\) and \(\mathrm {Im}(L_{f}) = {\mathbb {F}}_q\). If \(L_{f}(a)=-\frac{b}{2},\) we denote a by \(x_{b}\).

The following two lemmas are essential to prove our main results.

Lemma 6

[44, Lemma 5] Let the symbols and notation be as above and f be defined in (3) and \(b\in {\mathbb {F}}_{q}\). Then

  1. (1)

    \(\sum \limits _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{f(x)}=\varepsilon _{f}(p^{*})^{\frac{R_{f}}{2}}p^{e-R_f}\).

  2. (2)

    \( \sum \limits _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{f(x)-\mathrm {Tr}(bx)} =\left\{ \begin{array}{ll} 0, &{} \text {if } b\notin \mathrm {Im}(L_{f}), \\ \varepsilon _{f}(p^{*})^{\frac{R_{f}}{2}}p^{e-R_f}\zeta _{p}^{-f(x_{b})}, &{} \text {if } b\in \mathrm {Im}(L_{f}). \end{array} \right. \)

where \(x_{b}\) satisfies \(L_{f}(x_{b})=-\frac{b}{2}\).

Lemma 7

[44, Lemma 4] With the symbols and notation above, we have the following.

  1. (1)

    \( \sum \limits _{y\in {\mathbb {F}}_{p}^{*}}\sigma _{y}((p^{*})^{\frac{r}{2}}) =\left\{ \begin{array}{ll} 0, &{} \text {if } r \ \text {is odd }, \\ p^r(p^{*})^{-\frac{r}{2}}(p-1), &{} \text {if } r \ \text {is even }. \end{array} \right. \)

  2. (2)

    For any \(z\in {\mathbb {F}}_{p}^{*}\), then

    $$\begin{aligned} \sum \limits _{y\in {\mathbb {F}}_{p}^{*}}\sigma _{y}((p^{*})^{\frac{r}{2}}\zeta _{p}^{z}) =\left\{ \begin{array}{ll} {\bar{\eta }}(-z)p^r(p^{*})^{-\frac{r-1}{2}}, &{} \text {if } r \ \text {is odd }, \\ -p^r(p^{*})^{-\frac{r}{2}}, &{} \text {if } r \ \text {is even }. \end{array} \right. \end{aligned}$$

3 Linear codes from inhomogeneous quadratic functions

In this section, we study the weight distribution and weight hierarchy of \(C_\mathrm {D}\) in (5), where its defining set is

$$\begin{aligned} \mathrm {D}=\mathrm {D}_{\alpha }=\Big \{(x,y)\in {\mathbb {F}}_{q}^{2}\setminus \{(0,0)\}: f(x)+\mathrm {Tr}(\alpha y)=0\Big \}, \end{aligned}$$

with \(\alpha \in {\mathbb {F}}_{q}^{*}\) and f(x) is defined in (3) and non-degenerate.

3.1 The weight distribution of the presented linear code

In this subsection, we first calculate the length of \(C_{\mathrm {D}}\) defined in (5) and the Hamming weight of nonzero codewords of \( C_{\mathrm {D}}\).

Lemma 8

Let \(\alpha \in {\mathbb {F}}_{q}^{*}\) and \(\mathrm {D}\) be defined in (4) and \(C_{\mathrm {D}}\) be defined in (5). Define \(n=|\mathrm {D}|\). Then,

$$\begin{aligned} n=p^{2e-1}-1. \end{aligned}$$

Proof

By the orthogonal property of additive characters, we have

$$\begin{aligned} n&=\frac{1}{p}\sum _{x,y\in {\mathbb {F}}_{q}}\sum _{z\in {\mathbb {F}}_{p}}\zeta _{p}^{z\big (f(x)+\mathrm {Tr}(\alpha y)\big )}-1 \\&=\frac{1}{p}\sum _{x,y\in {\mathbb {F}}_{q}}\left( 1+\sum _{z\in {\mathbb {F}}_{p}^{*}}\zeta _{p}^{z\big (f(x)+\mathrm {Tr}(\alpha y)\big )}\right) -1 \\&=p^{2e-1}+\frac{1}{p}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sum _{y\in {\mathbb {F}}_{q}}\zeta _{p}^{\mathrm {Tr}(z\alpha y)}\sum _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{zf(x)}-1. \end{aligned}$$

The desired conclusion then follows from \(\alpha \ne 0\) and \( \sum _{y\in {\mathbb {F}}_{q}}\zeta _{p}^{\mathrm {Tr}(z\alpha y)}=0\). \(\square \)

Lemma 9

Let \(\alpha \in {\mathbb {F}}_{q}^{*}\) and \(\mathrm {D}\) be defined in (4) and \(C_{\mathrm {D}}\) be defined in (5). Let \(c_{(u,v)}\) be the corresponding codeword in \(C_{\mathrm {D}}\) with \((u,v)\in {\mathbb {F}}_{q}^{2}\). We have the following.

  1. (1)

    When \(v\in {\mathbb {F}}_{q}\setminus {\mathbb {F}}_{p}^{*}\alpha \), we have \(\mathrm {wt}(c_{(u,v)})=p^{2e-2}(p-1)\).

  2. (2)

    When \(v\in {\mathbb {F}}_{p}^{*}\alpha \), we have the following three cases.

    1. (2.1)

      If \(u=0\), then

      $$\begin{aligned} \mathrm {wt}(c_{(u,v)}) =\left\{ \begin{array}{ll} p^{2e-2}(p-1), &{} \text {if } e \ \text {is odd }, \\ p^{2e-2}(p-1)\Big (1-\varepsilon _{f}(p^{*})^{-\frac{e}{2}}\Big ), &{} \text {if } e \ \text {is even }. \end{array} \right. \end{aligned}$$
    2. (2.2)

      If \( u \ne 0 \) and \(f(x_{u})=0\), then

      $$\begin{aligned} \mathrm {wt}(c_{(u,v)}) =\left\{ \begin{array}{ll} p^{2e-2}(p-1), &{} \text {if } e \ \text {is odd }, \\ p^{2e-2}(p-1)\Big (1-\varepsilon _{f}(p^{*})^{-\frac{e}{2}}\Big ), &{} \text {if } e \ \text {is even }. \end{array} \right. \end{aligned}$$
    3. (2.3)

      If \( u \ne 0 \) and \(f(x_{u}) \ne 0 \), then

      $$\begin{aligned} \mathrm {wt}(c_{(u,v)}) =\left\{ \begin{array}{ll} p^{2e-2}\Big (p-1-\varepsilon _{f}{\bar{\eta }}(f(x_{u}))(p^{*})^{-\frac{e-1}{2}}\Big ), &{} \text {if } e \ \text {is odd }, \\ p^{2e-2}\Big (p-1+\varepsilon _{f}(p^{*})^{-\frac{e}{2}}\Big ), &{} \text {if } e \ \text {is even }. \end{array} \right. \end{aligned}$$

Proof

Put \(N(u,v)=\Big \{(x,y)\in {\mathbb {F}}_{q}^{2}: f(x)+\mathrm {Tr}(\alpha y)=0, \mathrm {Tr}(ux+vy) = 0\Big \}\), then the Hamming weight of \(c_{(u,v)}\) is \(n-|N(u,v)|+1\), where n is given in Lemma 8. Thus, we just need to evaluate the value of |N(uv)|.

By the orthogonal property of additive characters, we have

$$\begin{aligned} |N(u,v)|&=\frac{1}{p^{2}}\sum _{x,y\in {\mathbb {F}}_{q}}\left( \sum _{z_{1}\in {\mathbb {F}}_{p}}\zeta _{p}^{z_{1}f(x)+\mathrm {Tr}(z_{1}\alpha y)}\sum _{z_{2}\in {\mathbb {F}}_{p}}\zeta _{p}^{\mathrm {Tr}(z_{2}(ux+vy))}\right) \nonumber \\&=\frac{1}{p^{2}}\sum _{x,y\in {\mathbb {F}}_{q}}\left( \left( 1+\sum _{z_{1}\in {\mathbb {F}}_{p}^{*}}\zeta _{p}^{z_{1}f(x)+\mathrm {Tr}(z_{1}\alpha y)}\right) \left( 1+\sum _{z_{2}\in {\mathbb {F}}_{p}^{*}}\zeta _{p}^{\mathrm {Tr}(z_{2}(ux+vy))}\right) \right) \nonumber \\&=p^{2e-2}+\frac{1}{p^{2}}\sum _{z_{1}\in {\mathbb {F}}_{p}^{*}}\sum _{x,y\in {\mathbb {F}}_{q}}\zeta _{p}^{z_{1}f(x)+\mathrm {Tr}(z_{1}\alpha y)}+ \frac{1}{p^{2}}\sum _{z_{2}\in {\mathbb {F}}_{p}^{*}}\sum _{x,y\in {\mathbb {F}}_{q}}\zeta _{p}^{\mathrm {Tr}(z_{2}(ux+vy))} \nonumber \\&\quad +\frac{1}{p^{2}}\sum _{z_{1}\in {\mathbb {F}}_{p}^{*}}\sum _{z_{2}\in {\mathbb {F}}_{p}^{*}}\sum _{x,y\in {\mathbb {F}}_{q}}\zeta _{p}^{z_{1}f(x)+\mathrm {Tr}(z_{2}ux+z_{2}vy+z_{1}\alpha y)} \nonumber \\&=p^{2e-2}+p^{-2}\sum _{z_{1}\in {\mathbb {F}}_{p}^{*}}\sum _{z_{2}\in {\mathbb {F}}_{p}^{*}}\sum _{y\in {\mathbb {F}}_{q}}\zeta _{p}^{\mathrm {Tr}(z_{2}vy+z_{1}\alpha y)}\sum _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{z_{1}f(x)+\mathrm {Tr}(z_{2}ux)}. \end{aligned}$$
(8)
  1. (1)

    When \(v\in {\mathbb {F}}_{q}\setminus {\mathbb {F}}_{p}^{*}\alpha \), the desired conclusion then follows from

    $$\begin{aligned} \sum _{y\in {\mathbb {F}}_{q}}\zeta _{p}^{\mathrm {Tr}(z_{2}vy+z_{1}\alpha y)}=0. \end{aligned}$$
  2. (2)

    When \(v\in {\mathbb {F}}_{p}^{*}\alpha \), i.e., \(\alpha =zv\) for some \(z\in {\mathbb {F}}_{p}^{*}\), (8) becomes

    $$\begin{aligned} |N(u,v)|&=p^{2e-2}+p^{e-2}\sum _{z_{1}\in {\mathbb {F}}_{p}^{*}}\sum _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{z_{1}f(x)-z_{1}\mathrm {Tr}(zux)}\nonumber \\&=p^{2e-2}+p^{e-2}\sum _{z_{1}\in {\mathbb {F}}_{p}^{*}}\sigma _{z_{1}}\left( \sum _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{f(x)-\mathrm {Tr}(zux)}\right) . \end{aligned}$$
    (9)

    If \(u=0\), by Lemmas 6 and 7, we have

    $$\begin{aligned} |N(u,v)|&=p^{2e-2}+p^{e-2}\sum _{z_{1}\in {\mathbb {F}}_{p}^{*}}\sigma _{z_{1}}\Big (\varepsilon _{f}(p^{*})^{\frac{R_{f}}{2}}p^{e-R_f}\Big ) \\&=p^{2e-2}+p^{e-2}\varepsilon _{f}\sum _{z_{1}\in {\mathbb {F}}_{p}^{*}}\sigma _{z_{1}}\big ((p^{*})^{\frac{e}{2}}\big ) \\&=\left\{ \begin{array}{ll} p^{2e-2}, &{} \text {if } e \ \text {is odd }, \\ p^{2e-2}\Big (1+\varepsilon _{f}(p^{*})^{-\frac{e}{2}}(p-1)\Big ), &{} \text {if } e \ \text {is even }. \end{array} \right. \end{aligned}$$

    The desired conclusion of (2.1) is obtained. If \(u \ne 0 \), define \(c=zu\), we have \(x_{c}=zx_{u}\). By Lemma 6, (9) becomes

    $$\begin{aligned} |N(u,v)|&=p^{2e-2}+p^{e-2}\sum _{z_{1}\in {\mathbb {F}}_{p}^{*}}\sigma _{z_{1}}\Big (\varepsilon _{f}(p^{*})^{\frac{R_{f}}{2}}p^{e-R_f}\zeta _{p}^{-f(x_{c})}\Big ) \\&=p^{2e-2}+p^{e-2}\varepsilon _{f}\sum _{z_{1}\in {\mathbb {F}}_{p}^{*}}\sigma _{z_{1}}\Big ((p^{*})^{\frac{e}{2}}\zeta _{p}^{-f(x_{c})}\Big ). \end{aligned}$$

    The last two conclusions follow directly from Lemma 7. \(\square \)

Remark 1

By Lemma 9, we know that, for \((u,v)(\ne (0,0))\in {\mathbb {F}}_{q}^{2}\), we have \(\mathrm {wt}(c_{(u,v)})>0\). So, the map: \({\mathbb {F}}_{q}^{2}\rightarrow C_{\mathrm {D}}\) defined by \((u,v)\mapsto c_{(u,v)} \) is an isomorphism in linear spaces over \({\mathbb {F}}_{p}\). Hence, the dimension of the code \(C_{\mathrm {D}}\) in (5) is equal to 2e.

Lemma 10

Let \(C_{\mathrm {D}}\) be defined in (5). Then, the minimal distance of the dual code \(C_{\mathrm {D}}^{\perp }\) is at least 2.

Proof

We prove it by contradiction. If the minimal distance of the dual code \(C_{\mathrm {D}}^{\perp }\) is less than 2, then there exists a coordinate i such that the i-th entry of all of the codewords of \(C_{\mathrm {D}}\) is 0, that is, \(\mathrm {Tr}(ux+vy)=0\) for all \((u,v)\in {\mathbb {F}}_{q}^{2}\), where \((x,y)\in \mathrm {D}\). Thus, by the properties of the trace function, we have \((x,y)=(0,0)\). It contradicts with \((x,y) \ne (0,0)\). \(\square \)

Theorem 1

Let \(\alpha \in {\mathbb {F}}_{q}^{*}\) and f be a non-degenerate homogeneous quadratic function defined in (3). Let \(\mathrm {D}\) be defined in (4) and the code \(C_{\mathrm {D}}\) be defined in (5). Then the code \(C_{\mathrm {D}}\) is a \([p^{2e-1}-1,2e]\) linear code over \( {\mathbb {F}}_{p} \) with the weight distribution in Tables 1 and 2.

Table 1 The weight distribution of \(C_{\mathrm {D}}\) of Theorem 1 when e is odd
Table 2 The weight distribution of \(C_{\mathrm {D}}\) of Theorem 1 when e is even

Proof

By Lemma 8 and Remark 1, the code \(C_{\mathrm {D}}\) is a \([p^{2e-1}-1,2e]\) linear code over \( {\mathbb {F}}_{p} \). Now we shall prove the multiplicities \(A_{\omega _{i}}\) of codewords with weight \(\omega _{i}\) in \(C_{\mathrm {D}}\). Let us give the proofs of two cases, respectively.

(1) The case that e is odd.

For each \((u,v)\in {\mathbb {F}}_{q}^{2}\) and \( (u,v) \ne (0,0)\). By Lemmas 8 and 9, \(\mathrm {wt}(c_{(u,v)})\) has only three values, that is,

$$\begin{aligned} \left\{ \begin{array}{ll} \omega _{1}=(p-1)p^{2e-2}, \ \\ \omega _{2}=p^{2e-2}\Big (p-1-p^{-\frac{e-1}{2}}\Big ), \ \\ \omega _{3}=p^{2e-2}\Big (p-1+p^{-\frac{e-1}{2}}\Big ). \end{array} \right. \end{aligned}$$

By Lemma 9, we have

$$\begin{aligned} A_{\omega _{1}}&= \Big |\Big \{(u,v)\in {\mathbb {F}}_{q}^{2}|\mathrm {wt}(c_{(u,v)}) = (p-1)p^{2e-2}\Big \}\Big | \\&= \Big |\Big \{(u,v)\in {\mathbb {F}}_{q}^{2}\setminus \{(0,0)\}|u\in {\mathbb {F}}_{q},v\in {\mathbb {F}}_{q}\setminus {\mathbb {F}}_{p}^{*}\alpha \Big \}\Big |\\&\quad +\Big |\Big \{(0,v)\in {\mathbb {F}}_{q}^{2}|v\in {\mathbb {F}}_{p}^{*}\alpha \Big \}\Big |+\Big |\Big \{(u,v)\in {\mathbb {F}}_{q}^{2}|v\in {\mathbb {F}}_{p}^{*}\alpha , u\ne 0, f(x_u)=0\Big \}\Big |\\&=q\Big (q-(p-1)\Big )-1+(p-1)+(p-1)(p^{e-1}-1)\\&=p^{2e}-(p-1)^2p^{e-1}-1, \end{aligned}$$

where we use the fact that the number of nonzero solutions of the equation \(f(x)=0\) in \({\mathbb {F}}_{q}\) is \(p^{e-1}-1\) (see [32, Theorem 6.27]).

By Lemma 10 and the first two Pless power moments [18, p. 259], we obtain the system of linear equations as follows:

$$\begin{aligned} \left\{ \begin{array}{ll} A_{\omega _{1}}=p^{2e}-(p-1)^{2}p^{e-1}-1, \ \\ A_{\omega _{2}}+A_{\omega _{3}}=(p-1)^{2}p^{e-1}, \ \\ \omega _{1}A_{\omega _{1}}+\omega _{2}A_{\omega _{2}}+\omega _{3}A_{\omega _{3}}=p^{2e-1}(p^{2e-1}-1)(p-1). \end{array} \right. \end{aligned}$$

Solving the system, we get

$$\begin{aligned} \left\{ \begin{array}{ll} A_{\omega _{1}}=p^{2e}-(p-1)^{2}p^{e-1}-1, \ \\ A_{\omega _{2}}=\frac{1}{2}(p-1)^{2}p^{e-1}\Big (1+p^{-\frac{e-1}{2}}\Big ), \ \\ A_{\omega _{3}}=\frac{1}{2}(p-1)^{2}p^{e-1}\Big (1-p^{-\frac{e-1}{2}}\Big ). \end{array} \right. \end{aligned}$$

This completes the proof of the weight distribution of Table 1.

(2) The case that e is even.

The proof is similar to that of Case (1) and we omit it here. The desired conclusion then follows from Lemmas 8 and 9 and the first two Pless power moments. \(\square \)

Example 1

Let \((p,e,\alpha )=(5,3,1)\) and \(f(x)=\mathrm {Tr}(x^{2})\). Then, the corresponding code \(C_{\mathrm {D}}\) has parameters [3124, 6, 2375] and the weight enumerator \(1+240x^{2375}+15224x^{2500}+160x^{2625}\), which is verified by a Magma program.

Example 2

Let \((p,e,\alpha )=(3,4,1)\) and \(f(x)=\mathrm {Tr}(\theta x^{2})\), where \(\theta \) is a primitive element of \({\mathbb {F}}_{q}\). By Corollary 1 in [44], we have \(\varepsilon _{f}=1\). Then, the corresponding code \(C_{\mathrm {D}}\) has parameters [2186, 8, 1296] and the weight enumerator \(1+66x^{1296}+6398x^{1458}+96x^{1539}\), which is verified by a Magma program.

Example 3

Let \((p,e,\alpha )=(3,4,\theta )\) and \(f(x)=\mathrm {Tr}(x^{2})\), where \(\theta \) is a primitive element of \({\mathbb {F}}_{q}\). By Corollary 1 in [44], we have \(\varepsilon _{f}=-1\). Then, the corresponding code \(C_{\mathrm {D}}\) has parameters [2186, 8, 1377] and the weight enumerator \(1+120x^{1377}+6398x^{1458}+42x^{1620}\), which is verified by a Magma program.

3.2 The weight hierarchy of the presented linear code

In this subsection, we give the weight hierarchy of \(C_{\mathrm {D}}\) in (5).

By Remark 1, we know that the dimension of the code \(C_{\mathrm {D}}\) defined in (5) is 2e. So, by [31, Proposition 2.1], we give a general formula, that is

$$\begin{aligned} d_{r}(C_{\mathrm {D}})&=n-\max \Big \{|H_r^\perp \cap \mathrm {D}|: H_r \in [{\mathbb {F}}_{q}^{2},r]_{p}\Big \} \\&=n-\max \Big \{|H_{2e-r}\cap \mathrm {D}|: H_{2e-r} \in [{\mathbb {F}}_{q}^{2},2e-r]_{p}\Big \}, \end{aligned}$$
(10)

which will be employed to calculate the generalized Hamming weight \(d_r(C_\mathrm {D})\). Here \(H_r^\perp = \Big \{\mathrm {x}\in {\mathbb {F}}_{q}^{2}:\ \mathrm {Tr}(\mathrm {x}\cdot \mathrm {y}) =0, \text {for any } \mathrm {y}\in H_r \Big \}\).

Let \(H_r\) be an r-dimensional subspace of \({\mathbb {F}}_{q}^{2}\) and \(\beta _{1},\ldots ,\beta _{r}\) be an \({\mathbb {F}}_{p}\)-basis of \(H_r\). Set

$$\begin{aligned} N(H_r)=\Big \{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}: f(x)+\mathrm {Tr}(\alpha y)=0, \mathrm {Tr}(\mathrm {x}\cdot \beta _{i})=0, 1\le i\le r\Big \}. \end{aligned}$$

Then, \(N(H_r) = (H_r^\perp \cap \mathrm {D})\cup \{(0,0)\}\), which concludes that \(|N(H_r)|=|H_r^\perp \cap \mathrm {D} |+1\). Hence, we have

$$\begin{aligned} d_{r}(C_{\mathrm {D}})=n+1-\max \Big \{|N(H_r)|: H_r \in [{\mathbb {F}}_{q}^{2},r]_{p}\Big \}. \end{aligned}$$
(11)

Lemma 11

Let \(\alpha \in {\mathbb {F}}_{q}^{*}\) and f be a non-degenerate homogeneous quadratic function defined in (3) with the sign \(\varepsilon _f\). \(H_r\) and \(N(H_r)\) are defined as above. We have the following.

  1. (1)

    If \(\alpha \notin \mathrm {Prj}_{2}(H_r)\), then \(|N(H_r)|=p^{2e-(r+1)}\).

  2. (2)

    If \(\alpha \in \mathrm {Prj}_{2}(H_r)\), then

    $$\begin{aligned} |N(H_r)|=p^{e-(r+1)}\left( q+\varepsilon _{f}\sum \limits _{(y_1,-u)\in H_r}\sum \limits _{z\in {\mathbb {F}}_{p}^{*}}\sigma _{z}\Big ((p^{*})^{\frac{e}{2}}\zeta _{p}^{f(x_{y_1})}\Big )\right) . \end{aligned}$$

Here \( \mathrm {Prj}_{2}\) is the second projection from \({\mathbb {F}}_{q}^{2}\) to \({\mathbb {F}}_{q}\) defined by \((x,y)\mapsto y\).

Proof

By the orthogonal property of additive characters, we have

$$\begin{aligned} p^{r+1}|N(H_r)|&=\sum _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}}\sum _{z\in {\mathbb {F}}_{p}}\zeta _{p}^{z f(x)+\mathrm {Tr}(z\alpha y)}\prod _{i=1}^{r}\sum _{x_{i}\in {\mathbb {F}}_{p}}\zeta _{p}^{\mathrm {Tr}(x_{i}(\mathrm {x}\cdot \beta _{i}))} \\&=\sum _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}}\sum _{z\in {\mathbb {F}}_{p}}\zeta _{p}^{z f(x)+\mathrm {Tr}(z(\alpha y))}\sum _{\mathrm {y}\in H_r}\zeta _{p}^{\mathrm {Tr}(\mathrm {x}\cdot \mathrm {y})} \\&=\sum _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}}\sum _{\mathrm {y}\in H_r}\zeta _{p}^{\mathrm {Tr}(\mathrm {x}\cdot \mathrm {y})} +\sum _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sum _{\mathrm {y}\in H_r}\zeta _{p}^{z f(x)+\mathrm {Tr}(\mathrm {x}\cdot \mathrm {y}+z \alpha y)} \\&=q^{2}+\sum _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sum _{\mathrm {y}\in H_r}\zeta _{p}^{z f(x)+\mathrm {Tr}(\mathrm {x}\cdot \mathrm {y}+z \alpha y)}, \end{aligned}$$

where the last equation comes from

$$\begin{aligned} \sum _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}}\sum _{\mathrm {y}\in H_{r}}\zeta _{p}^{\mathrm {Tr}(\mathrm {y}\cdot \mathrm {x})}&=\sum _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}} \ 1+\sum _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}}\sum _{(0,0)\ne \mathrm {y}\in H_{r}}\zeta _{p}^{\mathrm {Tr}(\mathrm {y}\cdot \mathrm {x})} \\&=q^{2}+\sum _{(0,0)\ne \mathrm {y}\in H_{r}}\sum _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}}\zeta _{p}^{\mathrm {Tr}(\mathrm {y}\cdot \mathrm {x})}=q^{2}. \end{aligned}$$

Denote \(B_{H_r}=\sum \limits _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}}\sum \limits _{z\in {\mathbb {F}}_{p}^{*}}\sum \limits _{\mathrm {y}\in H_r}\zeta _{p}^{z f(x)+\mathrm {Tr}(\mathrm {x}\cdot \mathrm {y}+z \alpha y)}\), then we have

$$\begin{aligned} p^{r+1}|N(H_r)| = q^2+B_{H_r} \end{aligned}$$

and

$$\begin{aligned} B_{H_r}&=\sum _{\mathrm {x}=(x,y)\in {\mathbb {F}}_{q}^{2}}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sum _{\mathrm {y}\in H_r}\zeta _{p}^{z f(x)+\mathrm {Tr}(\mathrm {x}\cdot \mathrm {y}+z \alpha y)} \\&=\sum _{(x,y)\in {\mathbb {F}}_{q}^{2}}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sum _{(y_1,y_2)\in H_r}\zeta _{p}^{z f(x)+\mathrm {Tr}(y_1 x+y_2 y+z \alpha y)} \\&=\sum _{(y_1,y_2)\in H_r}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sum _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{z f(x)+\mathrm {Tr}(y_1x)}\sum _{y\in {\mathbb {F}}_{q}}\zeta _{p}^{\mathrm {Tr}(y_2y+z \alpha y)} \\&=\sum _{(y_1,y_2)\in H_r}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sum _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{z f(x)+z\mathrm {Tr}(\frac{y_1}{z}x)}\sum _{y\in {\mathbb {F}}_{q}}\zeta _{p}^{z\mathrm {Tr}(\frac{y_2}{z}y+\alpha y)} \\&=\sum _{(y_1,y_2)\in H_r}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sum _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{z f(x)+z\mathrm {Tr}(y_1x)}\sum _{y\in {\mathbb {F}}_{q}}\zeta _{p}^{z\mathrm {Tr}(y_2y+\alpha y)}. \nonumber \end{aligned}$$

If \(\alpha \notin \mathrm {Prj}_{2}(H_r)\), then \(B_{H_r}=0\), which follows from \(\sum _{y\in {\mathbb {F}}_{q}}\zeta _{p}^{z\mathrm {Tr}(y_2y+\alpha y)}=0\).

If \(\alpha \in \mathrm {Prj}_{2}(H_r)\), by Lemma 6, we have

$$\begin{aligned} B_{H_r}&=q\sum _{(y_1,-\alpha )\in H_r}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sum _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{z f(x)+z\mathrm {Tr}(y_1x)} \\&=q\sum _{(y_1,-\alpha )\in H_r}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sigma _{z}\Big (\sum _{x\in {\mathbb {F}}_{q}}\zeta _{p}^{f(x)+\mathrm {Tr}(y_1x)}\Big ) \\&=q\sum _{(y_1,-\alpha )\in H_r}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sigma _{z}\Big (\varepsilon _{f}(p^{*})^{\frac{R_{f}}{2}}p^{e-R_{f}}\zeta _{p}^{f(x_{y_1})}\Big ) \\&=\varepsilon _{f}q\sum _{(y_1,-\alpha )\in H_r}\sum _{z\in {\mathbb {F}}_{p}^{*}}\sigma _{z}\Big ((p^{*})^{\frac{e}{2}}\zeta _{p}^{f(x_{y_1})}\Big ). \nonumber \end{aligned}$$

So, the desired result is obtained. Thus, we complete the proof. \(\square \)

In the following, we shall determine the weight hierarchy of \(C_{\mathrm {D}}\) in (5) by calculating \(|N(H_r)|\) in Lemma 11 and \(|H_{2e-r}\cap \mathrm {D}|\) in (11).

Theorem 2

Let \(e\ge 3\) and \(\alpha \in {\mathbb {F}}_{q}^{*}\) and f be a non-degenerate homogeneous quadratic function defined in (3) with the sign \(\varepsilon _f\). Let \(\mathrm {D}\) be defined in (4) and the code \(C_{\mathrm {D}}\) be defined in (5). Define

$$\begin{aligned} e_0=\left\{ \begin{array}{ll} \frac{e-1}{2}, &{} \text {if } e \text { is odd}, \\ \frac{e}{2}, &{} \text {if } e \text { is even and } \varepsilon _{f}=(-1)^{\frac{e(p-1)}{4}},\\ \frac{e-2}{2}, &{} \text {if } e \text { is even and } \varepsilon _{f}=-(-1)^{\frac{e(p-1)}{4}}. \end{array} \right. \end{aligned}$$

Then we have the following.

  1. (1)

    When \(e-e_0+1 \le r \le 2e\), we have

    $$\begin{aligned} d_{r}(C_{\mathrm {D}})=p^{2e-1}-p^{2e-r}. \end{aligned}$$
  2. (2)

    When \(0< r\le e-e_0\), we have

    $$\begin{aligned} d_{r}(C_{\mathrm {D}})=\left\{ \begin{array}{ll} p^{2e-1}-p^{2e-r-1}-p^{\frac{3e-3}{2}}, \text {if } 2\not \mid e \}, \\ p^{2e-1}-p^{2e-r-1}-(p-1)p^{\frac{3e-4}{2}}, \text {if } 2\mid e \text { and } \varepsilon _{f}=(-1)^{\frac{e(p-1)}{4}},\\ p^{2e-1}-p^{2e-r-1}-p^{\frac{3e-4}{2}}, \text {if } 2\mid e \text { and } \varepsilon _{f}=-(-1)^{\frac{e(p-1)}{4}}. \end{array} \right. \end{aligned}$$

Proof

  1. (1)

    When \(e-e_0+1 \le r \le 2e\), then \(0 \le 2e-r \le e_0+e-1\). Let \(T_{\alpha }=\Big \{x\in {\mathbb {F}}_{q}:\ \mathrm {Tr}(\alpha x)=0\Big \}\). It is easy to know that \(\dim (T_{\alpha })=e-1\). By Lemmas 2 and 3, there exists an \(e_0\)-dimensional subspace \(J_{e_0}\) of \({\mathbb {F}}_{q}\) such that \(f(x)=0\) for any \(x\in J_{e_0}\). Note that the dimension of the subspace \(J_{e_0}\times T_{\alpha }\) is \(e_0+e-1\). Let \(H_{2e-r}\) be a \((2e-r)\)-dimensional subspace of \(J_{e_0}\times T_{\alpha }\), then, \(|H_{2e-r}\cap \mathrm {D}|=p^{2e-r}-1\). Hence, by (11), we have

    $$\begin{aligned} d_{r}(C_{\mathrm {D}})=n-\max \Big \{|\mathrm {D} \cap H|: H \in \big [{\mathbb {F}}_{p^{e}}^{2},2e-r\big ]_{p}\Big \}=p^{2e-1}-p^{2e-r}. \end{aligned}$$

    Thus, it remains to determine \(d_r(C_{\mathrm {D}})\) when \(0 < r \le e-e_0\).

  2. (2)

    When \(0 < r\le e-e_0\), we discuss case by case. Case 1 \(e (e\ge 3)\) is odd. In this case, \(e_0 = \frac{e-1}{2}\) and \(e-e_0 = \frac{e+1}{2}\), that is, \(0< r\le \frac{e+1}{2}\). When \(0< r < \frac{e+1}{2}\), let \(H_r\) be an r-dimensional subspace of \({\mathbb {F}}_{q}^{2}\). If \(\alpha \in \mathrm {Prj}_{2}(H_{r})\), by Lemmas 7 and 11, we have

    $$\begin{aligned} |N(H_r)|=p^{2e-(r+1)}\left( 1+(-1)^{\frac{(e-1)(p-1)}{4}}\varepsilon _{f}{\bar{\eta }}(-1)p^{-\frac{e-1}{2}}\sum _{(y_1,-\alpha )\in H_{r}}{\bar{\eta }}\big (f(x_{y_1})\big )\right) . \end{aligned}$$

    Now we want to construct \(H_r\) such that \(|N(H_r)|\) reaches its maximum, that is, the number of such as \((y_1,-\alpha )\) is maximal in \(H_{r}\) and for any \((y_1,-\alpha )\in H_{r}, {\bar{\eta }}(f(x_{y_1})) = (-1)^{\frac{(e-1)(p-1)}{4}}\varepsilon _{f}{\bar{\eta }}(-1)\). The constructing method is as follows. Taking an element \(a\in {\mathbb {F}}_{p}^{*}\) satisfying \({\overline{\eta }}(a)=(-1)^{\frac{(e-1)(p-1)}{4}}\varepsilon _{f}{\bar{\eta }}(-1)\), then, by Lemma 1 (or [32, Theorem 6.27]), we know that the length and the dimension of \(C_{{\overline{D}}_{a}}\) in (1) are \(p^{e-1}+{\bar{\eta }}(-1)p^{\frac{e-1}{2}}\) and e, respectively. Combining formula (11) with Lemma 5 ( or [28, Theorem 3] ), we have

    $$\begin{aligned} d_{e-r}(C_{{\overline{D}}_{a}})&=p^{e-1}+{\bar{\eta }}(-1)p^{\frac{e-1}{2}}-\max \Big \{|{\overline{D}}_{a} \cap H|: H \in [{\mathbb {F}}_{q},r]_{p}\Big \}\\&=p^{e-1}+{\bar{\eta }}(-1)p^{\frac{e-1}{2}}-2p^{e-(e-r)-1}, \end{aligned}$$

    which follows that \( \max \Big \{|{\overline{D}}_{a} \cap H|: H \in [{\mathbb {F}}_{q},r]_{p}\Big \}=2p^{r-1}\). Thus, there exists an r-dimensional subspace \(J_{r}\) of \({\mathbb {F}}_{q}\) such that \(|{\overline{D}}_{a} \cap J_r| = 2p^{r-1}\). By Lemma 1, we know that \(R_{J_{r}}=1\) and \(\varepsilon _{J_r}={\overline{\eta }}(a)\), which concludes that there exists an \((r-1)\)-dimensional subspace \(J_{r-1}\) of \(J_{r}\) satisfying \(f(J_{r-1})=0\) and \({\overline{\eta }}(f(x))=(-1)^{\frac{(e-1)(p-1)}{4}}\varepsilon _{f}{\bar{\eta }}(-1)\), for each \(x\in J_{r}\setminus J_{r-1}\). Let \(\alpha _{1},\alpha _{2},\ldots ,\alpha _{r-1}\) be an \({\mathbb {F}}_{p}\)-basis of \(J_{r-1}\). Take an element \(\alpha _{r}\in J_{r}\setminus J_{r-1}\) and set

    $$\begin{aligned} \mu _{1}=\alpha _{1}+\alpha _{r},\mu _{2}=\alpha _{2}+\alpha _{r},\ldots ,\mu _{r-1}=\alpha _{r-1}+\alpha _{r},\mu _{r}=\alpha _{r}, \end{aligned}$$

    clearly, \(\mu _{1},\mu _{2},\ldots ,\mu _{r-1},\mu _{r}\) is an \({\mathbb {F}}_{p}\)-basis of \(J_{r}\). Define

    $$\begin{aligned} \lambda _{1}=(\mu _{1},-\alpha ),\lambda _{2}=(\mu _{2},-\alpha ),\ldots ,\lambda _{r-1}=(\mu _{r-1},-\alpha ),\lambda _{r}=(\mu _{r},-\alpha ) \end{aligned}$$

    and \(V_{r}=\Big \langle \lambda _{1},\lambda _{2},\ldots ,\lambda _{r-1},\lambda _{r}\Big \rangle \), then \(V_{r}\) is an r-dimensional subspace of \({\mathbb {F}}_{q}^{2}\). Set \(S(-\alpha )=\Big \{(y,z)\in V_{r}:\ z=-\alpha \Big \}\), it is easy to know that the cardinal number of \(S(-\alpha )\) is \(p^{r-1}\). We assert that \(f(y)=f(\alpha _{r})\) for any \((y,-\alpha )\in S(-\alpha )\). In fact, \((y,-\alpha )\) has the following unique representation:

    $$\begin{aligned} (y,-\alpha )&=x_{1}\lambda _{1}+x_{2}\lambda _{2}+\cdots +x_{r-1}\lambda _{r-1}+x_{r}\lambda _{r},\\&=(x_{1}\alpha _{1}+x_{2}\alpha _{2}+\cdots +x_{r-1}\alpha _{r-1}+\alpha _{r},-\alpha ), x_{i}\in {\mathbb {F}}_{p}, \end{aligned}$$

    thus, we have \(y=x_{1}\alpha _{1}+x_{2}\alpha _{2}+\cdots +x_{r-1}\alpha _{r-1}+\alpha _{r}\), which concludes that \(f(y)=f(\alpha _{r})\). Take

    $$\begin{aligned} H_{r}=\Big \langle (L_f(\mu _{1}),-\alpha ),(L_f(\mu _{2}),-\alpha ),\ldots ,(L_f(\mu _{r-1}),-\alpha ),(L_f(\mu _{r}),-\alpha )\Big \rangle , \end{aligned}$$

    it is easily seen that \(H_{r}\) is our desired r-dimensional subspace of \({\mathbb {F}}_{q}^{2}\) and its \(|N(H_r)|\) reaches the maximum

    $$\begin{aligned} |N(H_r)|=p^{2e-(r+1)}\Big (1+p^{r-1-\frac{e-1}{2}}\Big ) = p^{2e-r-1} + p^{\frac{3e-3}{2}}. \end{aligned}$$

    So, for \(0< r < \frac{e+1}{2}\), the desired result is obtained by Lemma 11 and (12).

When \(r = \frac{e+1}{2}\), let \(H_r\) be an r-dimensional subspace of \({\mathbb {F}}_{q}^{2}\). By Lemmas 7 and 11, we have \(|N(H_r)|\le 2p^{\frac{3(e-1)}{2}}\), which concludes that

$$\begin{aligned} d_{r}(C_{\mathrm {D}})\ge p^{2e-1} - 2p^{\frac{3(e-1)}{2}} \end{aligned}$$

by formula (12). On the other hand, by formula (11), we have

$$\begin{aligned} d_{r}(C_{\mathrm {D}}) = p^{2e-1} -1 - \max \left\{ \Big |H_{\frac{3e-1}{2}}\cap \mathrm {D}\Big |: H_{\frac{3e-1}{2}} \in \left[ {\mathbb {F}}_{q}^{2},\frac{3e-1}{2}\right] _{p}\right\} . \end{aligned}$$

Now we want to construct a \(\frac{3e-1}{2}\)-dimensional subspace \(H_{\frac{3e-1}{2}}\) of \({\mathbb {F}}_{q}^{2}\) such that \(|H_{\frac{3e-1}{2}}\cap \mathrm {D}|\ge 2p^{\frac{3(e-1)}{2}}-1\), which concludes that

$$\begin{aligned} d_{r}(C_{\mathrm {D}})\le p^{2e-1} - 2p^{\frac{3(e-1)}{2}}. \end{aligned}$$

In fact, by the proof of (1), we know that the dimension of \( J_{\frac{e-1}{2}}\) is \( \frac{e-1}{2}\), then the dimension of \( J_{\frac{e-1}{2}}^{\perp _f}\) is \( \frac{e+1}{2}\). Taking \((u,v)\in \mathrm {D}\), where \(u\in J_{\frac{e-1}{2}}^{\perp _f}\) and \(f(u) \ne 0\), define \(H_{\frac{3e-1}{2}} = (J_{\frac{e-1}{2}}\times T_{\alpha }) \oplus \Big \langle (u,v) \Big \rangle \), then \(H_{\frac{3e-1}{2}}\) is our desired subspace of \({\mathbb {F}}_{q}^{2}\). So, for \(r = \frac{e+1}{2}\), we have

$$\begin{aligned} d_{r}(C_{\mathrm {D}}) = p^{2e-1} - 2p^{\frac{3(e-1)}{2}}. \end{aligned}$$

Case 2 \(e(e\ge 3) \) is even and \(\varepsilon _{f}=(-1)^{\frac{e(p-1)}{4}}\). In this case, \(e_0 = \frac{e}{2}\) and \(e-e_0 = \frac{e}{2}\), that is, \(0< r\le \frac{e}{2}\).

Suppose \(H_r\) is an r-dimensional subspace of \({\mathbb {F}}_{q}^{2}\) and \(\alpha \in \mathrm {Prj}_{2}(H_{r})\). Recall that \(v(0)=p-1\) and \(v(x)=-1\) for \(x\in {\mathbb {F}}_{p}^{*}\) defined in Lemma 1. By Lemmas 7 and 11, we have

$$\begin{aligned} |N(H_r)|&=p^{e-(r+1)}\left( q+\varepsilon _{f}\sum \limits _{(y_1,-u)\in H_r}\sum \limits _{z\in {\mathbb {F}}_{p}^{*}}\sigma _{z}\Big ((p^{*})^{\frac{e}{2}}\zeta _{p}^{f(x_{y_1})}\Big )\right) \\&=p^{2e-(r+1)}\left( 1+p^{-\frac{e}{2}}\sum _{(y_1,-\alpha )\in H_{r}}v(f(x_{y_1})\right) . \end{aligned}$$

Let \(J_{r}\) be a subspace of \(J_{\frac{e}{2}}\) with a basis \(\mu _{1},\mu _{2},\ldots ,\mu _{r}\). Take

$$\begin{aligned} H_{r}=\Big \langle (L_f(\mu _{1}),-\alpha ),(L_f(\mu _{2}),-\alpha ),\ldots ,(L_f(\mu _{r-1}),-\alpha ),(L_f(\mu _{r}),-\alpha )\Big \rangle , \end{aligned}$$

then \(|N(H_r)|\) reaches its maximum

$$\begin{aligned} |N(H_r)|=p^{2e-(r+1)}\Big (1+(p-1)p^{r-1-\frac{e}{2}}\Big ) = p^{2e-r-1} + (p-1)p^{\frac{3e-4}{2}}. \end{aligned}$$

So, for \(0< r\le \frac{e}{2}\), the desired result is obtained by Lemma 11 and (12).

Case 3 \(e (e\ge 3)\) is even and \(\varepsilon _{f}=-(-1)^{\frac{e(p-1)}{4}}\). In this case, \(e_0 = \frac{e-2}{2}\) and \(e-e_0 = \frac{e}{2}+1\), that is, \(0< r\le \frac{e}{2}+1\).

Suppose \(H_r\) is an r-dimensional subspace of \({\mathbb {F}}_{q}^{2}\) and \(\alpha \in \mathrm {Prj}_{2}(H_{r})\). By Lemmas 7 and 11, we have

$$\begin{aligned} |N(H_r)|=p^{2e-(r+1)}\Big (1-p^{-\frac{e}{2}}\sum _{(y_1,-\alpha )\in H_{r}}v(f(x_{y_1})\Big ). \nonumber \end{aligned}$$
(12)

Taking an element \(a\in {\mathbb {F}}_{p}^{*}\), then, by Lemma 1 (or [32, Theorem 6.26]), we know that the length and the dimension of \(C_{{\overline{D}}_{a}}\) in (1) are \(p^{e-1}+p^{\frac{e-2}{2}}\) and e, respectively.

When \(0< r\le \frac{e}{2}\), combining formula (11) with Lemma 4, we have

$$\begin{aligned} d_{e-r}(C_{{\overline{D}}_{a}})&=p^{e-1}+p^{\frac{e-2}{2}}-\max \Big \{|{\overline{D}}_{a} \cap H|: H \in [{\mathbb {F}}_{q},r]_{p}\Big \}\\&=p^{e-1}-2p^{e-(e-r)-1}+p^{\frac{e-2}{2}}, \end{aligned}$$

which follows that \(\max \Big \{|{\overline{D}}_{a} \cap H|: H \in [{\mathbb {F}}_{q},r]_{p}\Big \}=2p^{r-1}\). Thus, there exists an r-dimensional subspace \(J_{r}\) of \({\mathbb {F}}_{q}\) such that \(|{\overline{D}}_{a} \cap J_r| = 2p^{r-1}\). By Lemma 1, we know that \(R_{J_{r}}=1\) and \(\varepsilon _{J_r}={\overline{\eta }}(a)\), which concludes that there exists an \((r-1)\)-dimensional subspace \(J_{r-1}\) of \(J_{r}\) satisfying \(f(J_{r-1})=0\) and \({\overline{\eta }}(f(x))=(-1)^{\frac{(e-1)(p-1)}{4}}\varepsilon _{f}\), for each \(x\in J_{r}\setminus J_{r-1}\). Let \(\alpha _{1},\alpha _{2},\ldots ,\alpha _{r-1}\) be an \({\mathbb {F}}_{p}\)-basis of \(J_{r-1}\). Take an element \(\alpha _{r}\in J_{r}\setminus J_{r-1}\) and set

$$\begin{aligned} \mu _{1}=\alpha _{1}+\alpha _{r},\mu _{2}=\alpha _{2}+\alpha _{r},\ldots ,\mu _{r-1}=\alpha _{r-1}+\alpha _{r},\mu _{r}=\alpha _{r}, \end{aligned}$$

it’s obvious that \(\mu _{1},\mu _{2},\ldots ,\mu _{r-1},\mu _{r}\) is an \({\mathbb {F}}_{p}\)-basis of \(J_{r}\). Take

$$\begin{aligned} H_{r}=\Big \langle (L_f(\mu _{1}),-\alpha ),(L_f(\mu _{2}),-\alpha ),\ldots ,(L_f(\mu _{r-1}),-\alpha ),(L_f(\mu _{r}),-\alpha )\Big \rangle , \end{aligned}$$

then \(|N(H_r)|\) reaches its maximum

$$\begin{aligned} |N(H_r)|=p^{2e-(r+1)}\Big (1+p^{r-1-\frac{e}{2}}\Big ) = p^{2e-r-1} + p^{\frac{3e-4}{2}}. \end{aligned}$$

So, for \(0< r\le \frac{e}{2}\), the desired result is obtained by Lemma 11 and (12).

When \(r=\frac{e}{2}+1\), combining formula (11) with Lemma 4, we have

$$\begin{aligned} d_{e-r}(C_{{\overline{D}}_{a}})&=p^{e-1}+p^{\frac{e-2}{2}}-\max \Big \{|{\overline{D}}_{a} \cap H|: H \in [{\mathbb {F}}_{q},r]_{p}\Big \}\\&=p^{e-1}-p^{e-(e-r)-1}, \end{aligned}$$

which follows that \(\max \Big \{|{\overline{D}}_{a} \cap H|: H \in [{\mathbb {F}}_{q},\frac{e}{2}+1]_{p}\Big \}=p^{\frac{e}{2}}+p^{\frac{e-2}{2}}\). Thus, there exists an r-dimensional subspace \(J_{r}\) of \({\mathbb {F}}_{q}\) such that \(|{\overline{D}}_{a} \cap J_r| = p^{\frac{e-2}{2}}+p^{\frac{e}{2}}\). By the proof of Lemma 4 (or [28, Theorem 1]), we know that \(R_{J_r}=2\) and \(\varepsilon _{J_r}={\bar{\eta }}((-1)^{\frac{e}{2}-1})\varepsilon _f\). So, there exists an \((r-2)\)-dimensional subspace \(J_{r-2}\) of \( J_{r}\) satisfying \(f(J_{r-2})=0\). Let \(\alpha _{1},\alpha _{2},\ldots ,\alpha _{r-2}\) be an \({\mathbb {F}}_{p}\)-basis of \(J_{r-2}\). Choose two elements \(\gamma _{1}, \gamma _{2}\in J_{r}\setminus J_{r-2}\) such that \(\alpha _{1},\ldots ,\alpha _{r-2},\gamma _{1}, \gamma _{2}\) is an \({\mathbb {F}}_{p}\)-basis of \(J_{r}\). Set

$$\begin{aligned} \mu _{1}=\alpha _{1}+\gamma _{2},\ldots ,\mu _{r-2}=\alpha _{r-2}+\gamma _{2},\mu _{r-1}=\gamma _{1}+\gamma _{2},\mu _{r}=\gamma _{2}, \end{aligned}$$

it’s easy to see that \(\mu _{1},\mu _{2},\ldots ,\mu _{r-1},\mu _{r}\) is an \({\mathbb {F}}_{p}\)-basis of \(J_{r}\). Take \(H_{r}=\Big \langle (L_f(\mu _{1}),-\alpha ),(L_f(\mu _{2}),-\alpha ),\ldots ,(L_f(\mu _{r-1}),-\alpha ),(L_f(\mu _{r}),-\alpha )\Big \rangle \), then \(|N(H_r)|\) reaches its maximum

$$\begin{aligned} |N(H_r)|=p^{2e-(r+1)}\Big (1+p^{r-1-\frac{e}{2}}\Big ) = 2p^{\frac{3e-4}{2}}=p^{2e-r-1} + p^{\frac{3e-4}{2}}. \end{aligned}$$

So, for \( r=\frac{e}{2}+1\), the desired result is obtained. \(\square \)

4 Concluding remarks

In this paper, inspired by the works of [28, 44], we constructed a family of three-weight linear codes using a special inhomogeneous quadratic function, and determined their weight distributions and weight hierarchies. Compared with the codes Tang et al. constructed in [44], the obtained codes in this paper have different weight distributions. They are also different from the weight distributions in the classical families in [11, 51, 52]. In our case, we note that the quadratic form f defined in (3) is non-degenerate. It is an open problem to determine the weight hierarchy of the code when f is degenerate.

Let \(w_{\min }\) and \(w_{\max }\) denote the minimum and maximum nonzero weight of our obtained code \(C_{\mathrm {D}}\) defined in (5), respectively. If \(e\ge 3\), then it can be easily checked that

$$\begin{aligned} \frac{w_{\min }}{w_{\max }}> \frac{p-1}{p}. \end{aligned}$$

By the results in [1] and [50], we know that every nonzero codeword of \(C_{\mathrm {D}}\) is minimal and most of the codes we constructed are suitable for constructing secret sharing schemes with interesting properties.