Reed-Solomon 码RS(10,8)
具有d_min = n-k+1 = 3
最小距离。具有最小距离的代码d_min
可以纠正 t = floor((d_min-1) / 2)
符号错误或检测 d_min-1
符号错误。因此,您描述的代码可以检测到 2 个符号错误。
代码的代数结构确保所有具有d_min-1
或更少错误的有效码字将导致不等于零的校正子(这是存在错误的指示符)。
我创建了一个 Python 包galois,它在 Galois 字段上扩展了 NumPy 数组。由于代数 FEC 代码密切相关,因此我也将它们包括在内。实现了Reed-Solomon 代码以及detect()
方法。
下面是一个RS(10,8)
使用galois
. 在我的库中,RS(n-s,k-s)
通过首先创建完整代码RS(n,k)
然后将k-s
消息符号传递到encode()
orn-s
符号到decode()
or来使用缩短的代码detect()
。
In [1]: import galois
# Create the full code over GF(2^8) with d_min=3
In [2]: rs = galois.ReedSolomon(255, 253); rs
Out[2]: <Reed-Solomon Code: [255, 253, 3] over GF(2^8)>
# The Galois field the symbols are in
In [3]: GF = rs.field
In [4]: print(GF.properties)
GF(2^8):
characteristic: 2
degree: 8
order: 256
irreducible_poly: x^8 + x^4 + x^3 + x^2 + 1
is_primitive_poly: True
primitive_element: x
# Create a shortened message with 8 symbols
In [6]: message = GF.Zeros(8); message
Out[6]: GF([0, 0, 0, 0, 0, 0, 0, 0], order=2^8)
# Encode the message into a codeword with 10 symbols
In [7]: codeword = rs.encode(message); codeword
Out[7]: GF([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], order=2^8)
# Corrupt the first 2 symbols
In [8]: codeword[0:2] = [123, 234]; codeword
Out[8]: GF([123, 234, 0, 0, 0, 0, 0, 0, 0, 0], order=2^8)
# Decode the corrupted codeword, the corrected errors are -1 (meaning could not correctly decode)
In [9]: rs.decode(codeword, errors=True)
Out[9]: (GF([123, 234, 0, 0, 0, 0, 0, 0], order=2^8), -1)
# However, the RS code can correctly detect there are <= 2 errors
In [10]: rs.detect(codeword)
Out[10]: True