# Cyclic code

{{ safesubst:#invoke:Unsubst||$N=Technical |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }} In coding theory, a cyclic code is a block code, where the circular shifts of each codeword gives another word that belongs to the code. They are error-correcting codes that have algebraic properties that are convenient for efficient error detection and correction.

If 00010111 is a valid codeword, applying a right circular shift gives the string 10001011. If the code is cyclic, then 10001011 is again a valid codeword. In general, applying a right circular shift moves the least significant bit (LSB) to the leftmost position, so that it becomes the most significant bit (MSB); the other positions are shifted by 1 to the right.

## Definition

Let ${\displaystyle {\mathcal {C}}}$ be a linear code over a finite field ${\displaystyle GF(q)}$ of block length n. ${\displaystyle {\mathcal {C}}}$ is called a cyclic code if, for every codeword c=(c1,...,cn) from C, the word (cn,c1,...,cn-1) in ${\displaystyle GF(q)^{n}}$ obtained by a cyclic right shift of components is again a codeword. Because one cyclic right shift is equal to n − 1 cyclic left shifts, a cyclic code may also be defined via cyclic left shifts. Therefore the linear code ${\displaystyle {\mathcal {C}}}$ is cyclic precisely when it is invariant under all cyclic shifts.

Cyclic Codes have some additional structural constraint on the codes. They are based on Galois fields and because of their structural properties they are very useful for error controls. Their structure is strongly related to Galois fields because of which the encoding and decoding algorithms for cyclic codes are computationally efficient.

## Algebraic structure

Cyclic codes can be linked to ideals in certain rings. Let ${\displaystyle R=A[x]/(x^{n}-1)}$ be a polynomial ring over the finite field ${\displaystyle A=GF(q)}$. Identify the elements of the cyclic code C with polynomials in R such that ${\displaystyle (c_{0},\ldots ,c_{n-1})}$ maps to the polynomial ${\displaystyle c_{0}+c_{1}x+\cdots +c_{n-1}x^{n-1}}$: thus multiplication by x corresponds to a cyclic shift. Then C is an ideal in R, and hence principal, since R is a principal ideal ring. The ideal is generated by the unique monic element in C of minimum degree, the generator polynomial g.[1] This must be a divisor of ${\displaystyle x^{n}-1}$. It follows that every cyclic code is a polynomial code. If the generator polynomial g has degree d then the rank of the code C is ${\displaystyle n-d}$.

The idempotent of C is a codeword e such that e2 = e (that is, e is an idempotent element of C) and e is an identity for the code, that is e c = c for every codeword c. If n and q are coprime such a word always exists and is unique;[2] it is a generator of the code.

An irreducible code is a cyclic code in which the code, as an ideal is irreducible, i.e. is minimal in R, so that its check polynomial is an irreducible polynomial.

## Examples

For example, if A=${\displaystyle \mathbb {F} _{2}}$ and n=3, the set of codewords contained in the (1,1,0)-cyclic code is precisely

${\displaystyle ((0,0,0),(1,1,0),(0,1,1),(1,0,1))\,}$.

It corresponds to the ideal in ${\displaystyle \mathbb {F} _{2}[x]/(x^{3}-1)}$ generated by ${\displaystyle (1+x)}$.

Note that ${\displaystyle (1+x)}$ is an irreducible polynomial in the polynomial ring, and hence the code is an irreducible code.

The idempotent of this code is the polynomial ${\displaystyle x+x^{2}}$, corresponding to the codeword (1,1,0).

### Trivial examples

Trivial examples of cyclic codes are An itself and the code containing only the zero codeword. These correspond to generators 1 and ${\displaystyle x^{n}-1}$ respectively: these two polynomials must always be factors of ${\displaystyle x^{n}-1}$.

Over GF(2) the parity bit code, consisting of all words of even weight, corresponds to generator ${\displaystyle x+1}$. Again over GF(2) this must always be a factor of ${\displaystyle x^{n}-1}$.

## Quasi-cyclic codes and shortened codes

Before delving into the details of cyclic codes first we will discuss quasi-cyclic and shortened codes which are closely related to the cyclic codes and they all can be converted into each other.

### Definition

Quasi-cyclic codes: An ${\displaystyle (n,k)}$ quasi-cyclic code is a linear block code such that, for some ${\displaystyle b}$ coprime with ${\displaystyle n}$, the polynomial ${\displaystyle x^{b}c(x){\pmod {x^{n}-1}}}$ is a codeword polynomial whenever ${\displaystyle c(x)}$ is a codeword polynomial.

Here codeword polynomial is a linear code whose code words are polynomials that are divisible by a polynomial of shorter length called generator polynomial. Note that every codeword polynomial can be expressed in the form ${\displaystyle c(x)=a(x)g(x)}$. For any codeword ${\displaystyle (c_{0},..,c_{n-1})}$ codeword polynomial corresponds to the ${\displaystyle \sum _{i=0}^{n-1}c_{i}*x^{i}}$.

### Definition

Shortened codes: An ${\displaystyle [n,k]}$ linear code is called a proper shortened cyclic code if it can be obtained by deleting ${\displaystyle b}$ positions from an ${\displaystyle (n+b,k+b)}$ cyclic code.

In shortened codes information symbols are deleted to obtain a desired blocklength smaller than the design blocklength. The missing information symbols are usually imagined to be at the beginning of the codeword and are considered to be 0. Therefore, ${\displaystyle n}$${\displaystyle k}$ is fixed, and then ${\displaystyle k}$ is decreased which eventually decreases ${\displaystyle n}$. Note that it is not necessary to delete the starting symbols. Depending on the application sometimes consecutive positions are considered as 0 and are deleted.

All the symbols which are dropped need not be transmitted and at the receiving end can be reinserted. To convert ${\displaystyle (n,k)}$ cyclic code to ${\displaystyle (n-b,k-b)}$ shortened code, set ${\displaystyle b}$ symbols to zero and drop them from each codeword. Any cyclic code can be converted to quasi-cyclic codes by dropping every ${\displaystyle b}$th symbol where ${\displaystyle b}$ is a factor of ${\displaystyle n}$. If the dropped symbols are not check symbols then this cyclic code is also a shortened code.

## Cyclic codes for correcting errors

Now, we will begin the discussion of cyclic codes explicitly with error detection and correction. Cyclic codes can be used to correct errors, like Hamming codes as a cyclic codes can be used for correcting single error. Likewise, they are also used to correct double errors and burst errors. All types of error corrections are covered briefly in the further subsections.

The (7,4) Hamming code has a generator polynomial ${\displaystyle g(x)=x^{3}+x+1}$. This polynomial has a zero in Galois extension field ${\displaystyle GF(8)}$ at the primitive element ${\displaystyle \alpha }$, and all codewords satisfy ${\displaystyle {\mathcal {C}}(\alpha )=0}$. Cyclic codes can also be used to correct double errors over the field ${\displaystyle GF(2)}$. Blocklength will be ${\displaystyle n}$ equal to ${\displaystyle 2^{m}-1}$ and primitive elements ${\displaystyle \alpha }$ and ${\displaystyle \alpha ^{3}}$ as zeros in the ${\displaystyle GF(2^{m})}$ because we are considering the case of two errors here, so each will represent one error.

The received word is a polynomial of degree ${\displaystyle n-1}$ given as ${\displaystyle v(x)=a(x)g(x)+e(x)}$

where ${\displaystyle e(x)}$ can have at most two nonzero coefficients corresponding to 2 errors.

We define the Syndrome Polynomial, ${\displaystyle S(x)}$ as the remainder of polynomial ${\displaystyle v(x)}$ when divided by the generator polynomial ${\displaystyle g(x)}$ i.e.

### For correcting two errors

Let the field elements ${\displaystyle X_{1}}$ and ${\displaystyle X_{2}}$ be the two error location numbers. If only one error occurs then ${\displaystyle X_{2}}$ is equal to zero and if none occurs both are zero.

These field elements are called "syndromes". Now because ${\displaystyle g(x)}$ is zero at primitive elements ${\displaystyle \alpha }$ and ${\displaystyle \alpha ^{3}}$, so we can write ${\displaystyle S_{1}=e(\alpha )}$ and ${\displaystyle S_{3}=e(\alpha ^{3})}$. If say two errors occur, then

And these two can be considered as two pair of equations in ${\displaystyle GF(2^{m})}$ with two unknowns and hence we can write

Hence if the two pair of nonlinear equations can be solved cyclic codes can used to correct two errors.

## Hamming code

The Hamming(7,4) code may be written as a cyclic code over GF(2) with generator ${\displaystyle 1+x+x^{3}}$. In fact, any binary Hamming code of the form Ham(r, 2) is equivalent to a cyclic code,[3] and any Hamming code of the form Ham(r,q) with r and q-1 relatively prime is also equivalent to a cyclic code.[4] Given a Hamming code of the form Ham(r,2) with ${\displaystyle r\geq 3}$, the set of even codewords forms a cyclic ${\displaystyle [2^{r}-1,2^{r}-r-2,4]}$-code.[5]

### Hamming code for correcting single errors

A code whose minimum distance is at least 3, have a check matrix all of whose columns are distinct and non zero. If a check matrix for a binary code has ${\displaystyle m}$ rows, then each column is an ${\displaystyle m}$-bit binary number. There are ${\displaystyle 2^{m}-1}$ possible columns. Therefore if a check matrix of a binary code with ${\displaystyle d_{min}}$ at least 3 has ${\displaystyle m}$ rows, then it can only have ${\displaystyle 2^{m}-1}$ columns, not more than that. This defines a ${\displaystyle (2^{m}-1,2^{m}-1-m)}$ code, called Hamming code.

It is easy to define Hamming codes for large alphabets of size ${\displaystyle q}$. We need to define one ${\displaystyle H}$ matrix with linearly independent columns. For any word of size ${\displaystyle q}$ there will be columns who are multiples of each other. So, to get linear independence all non zero ${\displaystyle m}$-tuples with one as a top most non zero element will be chosen as columns. Then two columns will never be linearly dependent because three columns could be linearly dependent with the minimum distance of the code as 3.

So, there are ${\displaystyle (q^{m}-1)/(q-1)}$ nonzero columns with one as top most non zero element. Therefore, Hamming code is a ${\displaystyle [(q^{m}-1)/(q-1),(q^{m}-1)/(q-1)-m]}$ code.

Now, for cyclic codes, Let ${\displaystyle \alpha }$ be primitive element in ${\displaystyle GF(q^{m})}$, and let ${\displaystyle \beta =\alpha ^{q-1}}$. Then ${\displaystyle \beta ^{(q^{m}-1)/(q-1)}=1}$ and thus ${\displaystyle \beta }$ is a zero of the polynomial ${\displaystyle x^{(q^{m}-1)/(q-1)}-1}$ and is a generator polynomial for the cyclic code of block length ${\displaystyle n=(q^{m}-1)/(q-1)}$.

But for ${\displaystyle q=2}$, ${\displaystyle \alpha =\beta }$. And the received word is a polynomial of degree ${\displaystyle n-1}$ given as

where, ${\displaystyle e(x)=0}$ or ${\displaystyle x^{i}}$ where ${\displaystyle i}$ represents the error locations.

But we can also use ${\displaystyle \alpha ^{i}}$ as an element of ${\displaystyle GF(2^{m})}$ to index error location. Because ${\displaystyle g(\alpha )=0}$, we have ${\displaystyle v(\alpha )=\alpha ^{i}}$ and all powers of ${\displaystyle \alpha }$ from ${\displaystyle 0}$ to ${\displaystyle 2^{m}-2}$ are distinct. Therefore we can easily determine error location ${\displaystyle i}$ from ${\displaystyle \alpha ^{i}}$ unless ${\displaystyle v(\alpha )=0}$ which represents no error. So, hamming code is a single error correcting code over ${\displaystyle GF(2)}$ with ${\displaystyle n=2^{m}-1}$ and ${\displaystyle k=n-m}$.

## Cyclic codes for correcting burst errors

From Hamming distance concept, a code with minimum distance ${\displaystyle 2t+1}$ can correct any ${\displaystyle t}$ errors. But in many channels error pattern is not very arbitrary, it occurs within very short segment of the message. Such kind of errors are called burst errors. So, for correcting such errors we will get a more efficient code of higher rate because of the less constraints. Cyclic codes are used for correcting burst error. In fact, cyclic codes can also correct cyclic burst errors along with burst errors. Cyclic burst errors are defined as

A cyclic burst of length ${\displaystyle t}$ is a vector whose nonzero components are among ${\displaystyle t}$ (cyclically) consecutive components, the first and the last of which are nonzero.

In polynomial form cyclic burst of length ${\displaystyle t}$ can be described as ${\displaystyle e(x)=x^{i}b(x)\mod (x^{n}-1)}$ with ${\displaystyle b(x)}$ as a polynomial of degree ${\displaystyle t-1}$ with nonzero coefficient ${\displaystyle b_{0}}$. Here ${\displaystyle b(x)}$ defines the pattern and ${\displaystyle x^{i}}$ defines the starting point of error. Length of the pattern is given by deg${\displaystyle b(x)+1}$. Syndrome poynomial is unique for each pattern and is given by

A linear block code that corrects all burst errors of length ${\displaystyle t}$ or less must have at least ${\displaystyle 2t}$ check symbols. Proof: Because any linear code that can correct burst pattern of length ${\displaystyle t}$ or less cannot have a burst of length ${\displaystyle 2t}$ or less as a codeword because if it did then a burst of length ${\displaystyle t}$ could change the codeword to burst pattern of length ${\displaystyle t}$, which also could be obtained by making a burst error of length ${\displaystyle t}$ in all zero codeword. Now, any two vectors that are non zero in the first ${\displaystyle 2t}$ components must be from different co-sets of an array to avoid their difference being a codeword of bursts of length ${\displaystyle 2t}$. Therefore number of such co-sets are equal to number of such vectors which are ${\displaystyle q^{2t}}$. Hence at least ${\displaystyle q^{2t}}$ co-sets and hence at least ${\displaystyle 2t}$ check symbol.

This property is also known as Rieger bound and it is similar to the singleton bound for random error correcting.

### Fire codes as cyclic bounds

In 1959, Philip Fire[6] presented a construction of cyclic codes generated by a product of a binomial and a primitive polynomial. The binomial has the form ${\displaystyle x^{c}+1}$ for some positive odd integer ${\displaystyle c}$.[7] Fire code is a cyclic burst error correcting code over ${\displaystyle GF(q)}$ with the generator polynomial

where ${\displaystyle p(x)}$ is a prime polynomial with degree ${\displaystyle m}$ not smaller than ${\displaystyle t}$ and ${\displaystyle p(x)}$ does not divide ${\displaystyle x^{2t-1}-1}$. Block length of the fire code is the smallest integer ${\displaystyle n}$ such that ${\displaystyle g(x)}$ divides ${\displaystyle x^{n}-1}$.

A fire code can correct all burst errors of length t or less if no two bursts ${\displaystyle b(x)}$ and ${\displaystyle x^{j}b'(x)}$ appear in the same co-set. This can be proved by contradiction. Suppose there are two distinct nonzero bursts ${\displaystyle b(x)}$ and ${\displaystyle x^{j}b'(x)}$ of length ${\displaystyle t}$ or less and are in the same co-set of the code. So, their difference is a codeword. As the difference is a multiple of ${\displaystyle g(x)}$ it is also a multiple of ${\displaystyle x^{2t-1}-1}$. Therefore,

This shows that ${\displaystyle j}$ is a multiple of ${\displaystyle 2t-1}$, So

Since ${\displaystyle b(x)}$ degree is less than degree of ${\displaystyle p(x)}$,${\displaystyle p(x)}$ cannot divide ${\displaystyle b(x)}$. If ${\displaystyle l}$ is not zero, then ${\displaystyle p(x)}$ also cannot divide ${\displaystyle x^{l(2t-1)}-1}$ as ${\displaystyle l}$ is less than ${\displaystyle q^{m}-1}$ and by definition of ${\displaystyle m}$, ${\displaystyle p(x)}$ divides ${\displaystyle x^{l(2t-1)}-1}$ for no ${\displaystyle l}$ smaller than ${\displaystyle q^{m}-1}$. Therefore ${\displaystyle l}$ and ${\displaystyle j}$ equals to zero. That means both that both the bursts are same, contrary to assumption.

Fire codes are the best single burst correcting codes with high rate and they are constructed analytically. They are of very high rate and when ${\displaystyle m}$ and ${\displaystyle t}$ are equal, redundancy is least and is equal to ${\displaystyle 3t-1}$. By using multiple fire codes longer burst errors can also be corrected.

For error detection cyclic codes are widely used and are called ${\displaystyle t-1}$ cyclic redundancy codes.

## Cyclic codes on Fourier transform

Applications of Fourier transform are widespread in signal processing. But their applications are not limited to the complex fields only; Fourier transforms also exist in the Galois field ${\displaystyle GF(q)}$. Cyclic codes using Fourier transform can be described in a setting closer to the signal processing.

### Fourier transform over finite fields

The discrete Fourier transform of vector ${\displaystyle v=v_{0},v_{1},....,v_{n-1}}$ is given by a vector ${\displaystyle V=V_{0},V_{1},.....,V_{n-1}}$ where,

where exp(${\displaystyle -j2\pi /n}$) is an ${\displaystyle n}$th root of unity. Similarly in the finite field ${\displaystyle n}$th root of unity is element ${\displaystyle \omega }$ of order ${\displaystyle n}$. Therefore

If ${\displaystyle v=(v_{0},v_{1},....,v_{n-1})}$ is a vector over ${\displaystyle GF(q)}$, and ${\displaystyle \omega }$ be an element of ${\displaystyle GF(q)}$ of order ${\displaystyle n}$, then Fourier transform of the vector ${\displaystyle v}$ is the vector ${\displaystyle V=(V_{0},V_{1},.....,V_{n-1})}$ and components are given by

Here ${\displaystyle i}$ is time index, ${\displaystyle j}$ is frequency and ${\displaystyle V}$ is the spectrum. One important difference between Fourier transform in complex field and Galois field is that complex field ${\displaystyle \omega }$ exists for every value of ${\displaystyle n}$ while in Galois field ${\displaystyle \omega }$ exists only if ${\displaystyle n}$ divides ${\displaystyle q-1}$. In case of extension fields, there will be a Fourier transform in the extension field ${\displaystyle GF(q^{m})}$ if ${\displaystyle n}$ divides ${\displaystyle q^{m}-1}$ for some ${\displaystyle m}$. In Galois field time domain vector ${\displaystyle v}$ is over the field ${\displaystyle GF(q)}$ but the spectrum ${\displaystyle V}$ may be over the extension field ${\displaystyle GF(q^{m})}$.

### Spectral description of cyclic codes

Any codeword of cyclic code of blocklength ${\displaystyle n}$ can be represented by a polynomial ${\displaystyle c(x)}$ of degree at most ${\displaystyle n-1}$. Its encoder can be written as ${\displaystyle c(x)=a(x)g(x)}$. Therefore in frequency domain encoder can be written as ${\displaystyle C_{j}=A_{j}G_{j}}$. Here codeword spectrum ${\displaystyle C_{j}}$ has a value in ${\displaystyle GF(q^{m})}$ but all the components in the time domain are from ${\displaystyle GF(q)}$. As the data spectrum ${\displaystyle A_{j}}$ is arbitrary, the role of ${\displaystyle G_{j}}$ is to specify those ${\displaystyle j}$ where ${\displaystyle C_{j}}$ will be zero.

Thus, cyclic codes can also be defined as

Given a set of spectral indices, ${\displaystyle A=(j_{1},....,j_{n-k})}$, whose elements are called check frequencies, the cyclic code ${\displaystyle C}$ is the set of words over ${\displaystyle GF(q)}$ whose spectrum is zero in the components indexed by ${\displaystyle j_{1},...,j_{n-k}}$. Any such spectrum ${\displaystyle C}$ will have components of the form ${\displaystyle A_{j}G_{j}}$.

So, cyclic codes are vectors in the field ${\displaystyle GF(q)}$ and the spectrum given by its inverse fourier transform is over the field ${\displaystyle GF(q^{m})}$ and are constrained to be zero at certain components. But note that every spectrum in the field ${\displaystyle GF(q^{m})}$ and zero at certain components may not have inverse transforms with components in the field ${\displaystyle GF(q)}$. Such spectrum can not be used as cyclic codes.

Following are the few bounds on the spectrum of cyclic codes.

#### BCH bound

If ${\displaystyle n}$ be a factor of ${\displaystyle (q^{m}-1)}$ for some ${\displaystyle m}$. The only vector in ${\displaystyle GF(q)^{n}}$ of weight ${\displaystyle d-1}$ or less that has ${\displaystyle d-1}$ consecutive components of its spectrum equal to zero is all-zero vector.

### Quadratic residue codes

When the prime ${\displaystyle l}$ is a quadratic residue modulo the prime ${\displaystyle p}$ there is a quadratic residue code which is a cyclic code of length ${\displaystyle p}$, dimension ${\displaystyle (p+1)/2}$ and minimum weight at least ${\displaystyle {\sqrt {p}}}$ over ${\displaystyle GF(l)}$.

## Generalizations

A constacyclic code is a linear code with the property that for some constant λ if (c1,c2,...,cn) is a codeword then so is (λcn,c1,...,cn-1). A negacyclic code is a constacyclic code with λ=-1.[8] A quasi-cyclic code has the property that for some s, any cyclic shift of a codeword by s places is again a codeword.[9] A double circulant code is a quasi-cyclic code of even length with s=2.[9]

## Notes

1. Template:Harvnb
2. Template:Harvnb
3. Template:Harvnb
4. Template:Harvnb
5. Template:Harvnb
6. P. Fire, E, P. (1959). A class of multiple-error-correcting binary codes for non-independent errors. Sylvania Reconnaissance Systems Laboratory, Mountain View, CA, Rept. RSL-E-2, 1959.
7. Wei Zhou, Shu Lin, Khaled Abdel-Ghaffar. Burst or random error correction based on Fire and BCH codes. ITA 2014: 1-5 2013.
8. Template:Harvnb
9. Template:Harvnb

## References

• {{#invoke:citation/CS1|citation

|CitationClass=citation }}

• {{#invoke:citation/CS1|citation

|CitationClass=citation }}

• {{#invoke:citation/CS1|citation

|CitationClass=citation }}

• {{#invoke:citation/CS1|citation

|CitationClass=citation }}