-
galois.ReedSolomon(n: int, k: int | None =
None
, d: int | None =None
, field: type[FieldArray] | None =None
, alpha: ElementLike | None =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: int | None =
None
¶ The message size \(k\).
Important
Either
k
ord
must be provided to define the code. Both may be provided as long as they are consistent.- d: int | None =
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: type[FieldArray] | None =
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 usematlab_primitive_poly(2, m)
for the irreducible polynomial.- alpha: ElementLike | None =
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 [1]: galois.ReedSolomon(255, 223) Out[1]: <Reed-Solomon Code: [255, 223, 33] over GF(2^8)> In [2]: galois.ReedSolomon(255, d=33) Out[2]: <Reed-Solomon Code: [255, 223, 33] over GF(2^8)> In [3]: galois.ReedSolomon(255, 223, 33) Out[3]: <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 [4]: GF = galois.GF(2**8) In [5]: galois.ReedSolomon(85, 65, field=GF) Out[5]: <Reed-Solomon Code: [85, 65, 21] over GF(2^8)> In [6]: galois.ReedSolomon(85, d=21, field=GF) Out[6]: <Reed-Solomon Code: [85, 65, 21] over GF(2^8)> In [7]: galois.ReedSolomon(85, 65, 21, field=GF) Out[7]: <Reed-Solomon Code: [85, 65, 21] over GF(2^8)>