galois.ReedSolomon(n: int, k: = None, d: = None, field: = None, alpha: = None, c: int = 1, systematic: bool = True)

Constructs a general $$\textrm{RS}(n, k)$$ code over $$\mathrm{GF}(q)$$.

Parameters:
n: int

The codeword size $$n$$. If $$n = q - 1$$, the Reed-Solomon code is primitive.

k: = None

The message size $$k$$.

Important

Either k or d must be provided to define the code. Both may be provided as long as they are consistent.

d: = None

The design distance $$d$$. This defines the number of roots $$d - 1$$ in the generator polynomial $$g(x)$$ over $$\mathrm{GF}(q)$$. Reed-Solomon codes achieve the Singleton bound, so $$d = n - k + 1$$.

field: = None

The Galois field $$\mathrm{GF}(q)$$ that defines the alphabet of the codeword symbols. The default is None which corresponds to $$\mathrm{GF}(2^m)$$ where $$2^{m - 1} \le n < 2^m$$. The default field will use matlab_primitive_poly(2, m) for the irreducible polynomial.

alpha: = None

A primitive $$n$$-th root of unity $$\alpha$$ in $$\mathrm{GF}(q)$$ that defines the $$\alpha^c, \dots, \alpha^{c+d-2}$$ roots of the generator polynomial $$g(x)$$.

c: int = 1

The first consecutive power $$c$$ of $$\alpha$$ that defines the $$\alpha^c, \dots, \alpha^{c+d-2}$$ roots of the generator polynomial $$g(x)$$. The default is 1. If $$c = 1$$, the Reed-Solomon code is narrow-sense.

systematic: bool = True

Indicates if the encoding should be systematic, meaning the codeword is the message with parity appended. The default is True.

Examples

Construct a primitive, narrow-sense $$\textrm{RS}(255, 223)$$ code over $$\mathrm{GF}(2^8)$$.

In : galois.ReedSolomon(255, 223)
Out: <Reed-Solomon Code: [255, 223, 33] over GF(2^8)>

In : galois.ReedSolomon(255, d=33)
Out: <Reed-Solomon Code: [255, 223, 33] over GF(2^8)>

In : galois.ReedSolomon(255, 223, 33)
Out: <Reed-Solomon Code: [255, 223, 33] over GF(2^8)>


Construct a non-primitive, narrow-sense $$\textrm{RS}(85, 65)$$ code over $$\mathrm{GF}(2^8)$$.

In : GF = galois.GF(2**8)

In : galois.ReedSolomon(85, 65, field=GF)
Out: <Reed-Solomon Code: [85, 65, 21] over GF(2^8)>

In : galois.ReedSolomon(85, d=21, field=GF)
Out: <Reed-Solomon Code: [85, 65, 21] over GF(2^8)>

In : galois.ReedSolomon(85, 65, 21, field=GF)
Out: <Reed-Solomon Code: [85, 65, 21] over GF(2^8)>