# bchgenpoly

Produce generator polynomials for BCH code

## Description

example

genpoly = bchgenpoly(N,K) returns the narrow-sense generator polynomial of a BCH code with codeword length N and message length K. For more information, see Generator Polynomial of a BCH Code.

example

genpoly = bchgenpoly(N,K,prim_poly) also specifies the primitive polynomial.

example

genpoly = bchgenpoly(N,K,prim_poly,outputFormat) also specifies the output format of genpoly as a Galois field array or double-precision array.

example

[genpoly,T] = bchgenpoly(___) also returns T, the error-correction capability of the code when using any of the previous syntaxes.

## Examples

collapse all

Create two BCH generator polynomials based on different primitive polynomials.

Set the codeword and message lengths, n and k.

n = 15;
k = 11;

Create the generator polynomial and return the error correction capability, t.

[genpoly,t] = bchgenpoly(15,11)

genpoly = GF(2) array.

Array elements =

1   0   0   1   1
t = 1

Create a generator polynomial for a (15,11) BCH code using a different primitive polynomial expressed as a character vector. Note that genpoly2 differs from genpoly, which uses the default primitive.

genpoly2 = bchgenpoly(15,11,'D^4 + D^3 + 1')

genpoly2 = GF(2) array.

Array elements =

1   1   0   0   1

## Input Arguments

collapse all

Codeword length, specified as an integer of the form N = 2M – 1, where M is an integer in the range [3, 16]. For more information, see Limitations.

Example: 15 for M=4

Message length, specified as an integer. N and K must produce a narrow-sense BCH code. To generate the list of valid (N,K) pairs along with the corresponding values of the error-correction capability, run bchnumerr(N). For more information, see Limitations.

Example: 5 specifies a Galois array with five elements

Primitive polynomial, specified as:

Example: 'D^4+D+1' specifies the primitive polynomial D4+D+1.

Example: 19 specifies the primitive polynomial D4+D+1 because its binary representation is 10011.

Output format of genpoly, specified as:

• 'gf' — to output a Galois field array.

• 'double' — to output a double-precision array of the Galois field values.

## Output Arguments

collapse all

Generator polynomial coefficients, returned as a row vector that represents the coefficients of the narrow-sense generator polynomial of an [N,K] BCH code in order of descending powers. Specify the output datatype with the outputFormat property.

Data Types: gf | double

Error correction capability, returned as a positive integer.

## Limitations

• Valid values for N = 2M – 1, where M is an integer in the range [3, 16]. The maximum allowable value of N = 216 – 1 = 65,535.

• Valid values for K = [1, (N – 1)].

## Algorithms

collapse all

For a description of Bose–Chaudhuri–Hocquenghem (BCH) coding, see [1]. Although bchgenpoly performs intermediate computations in GF(N + 1), the output form is a Galois vector in GF(2).

### Generator Polynomial of a BCH Code

The narrow-sense generator polynomial of a BCH code with codeword length N and message length K is LCM[m1(x), m2(x), ..., m2T(x)], where:

• LCM represents the least common multiple,

• mi(x) represents the minimum polynomial corresponding to αi, α is a root of the default primitive polynomial for the field GF(N + 1),

• T represents the error-correcting capability of the code.

### Default Primitive Polynomials

This table lists the default primitive polynomial used for each Galois field array GF(2m). To use a different primitive polynomial, specify prim_poly as an input argument. prim_poly must be in the range [(2m + 1), (2m+1 – 1)] and must indicate an irreducible polynomial. For more information, see Primitive Polynomials and Element Representations.

Value of mDefault Primitive PolynomialInteger Representation
1D + 13
2D2 + D + 17
3D3 + D + 111
4D4 + D + 119
5D5 + D2 + 137
6D6 + D + 167
7D7 + D3 + 1137
8D8 + D4 + D3 + D2 + 1285
9D9 + D4 + 1529
10D10 + D3 + 11033
11D11 + D2 + 12053
12D12 + D6 + D4 + D + 14179
13D13 + D4 + D3 + D + 18219
14D14 + D10 + D6 + D + 117475
15D15 + D + 132771
16D16 + D12 + D3 + D + 169643

## References

[1] Peterson, W. Wesley, and E. J. Weldon. Error-correcting Codes.1972.

## Version History

Introduced before R2006a