Berlekamp-Massey 算法的 Python 3 实现。
$ python main.py -h
usage: main.py [-h] [-d {1,2,3}] [-l {ch,en}] [-v VERSION] flow
$ python main.py 10011011000111010100
输入序列为:10011011000111010100
可以生成此序列的最优为 11 级线性反馈移位寄存器
该寄存器的连接多项式为:f(x) = 1 + x^3 + x^9 + x^11
$ python main.py -d 1 10011011000111010100
f1(x) = 1 + x
f2(x) = 1
f4(x) = 1 + x^3
f5(x) = 1 + x + x^3
f6(x) = 1 + x + x^2 + x^3
f7(x) = 1 + x + x^2
f10(x) = 1 + x + x^2 + x^3 + x^4 + x^5 + x^6
f11(x) = 1 + x^4 + x^5 + x^6
f12(x) = 1 + x^2 + x^3 + x^5 + x^6
f13(x) = 1 + x^2 + x^4 + x^6
f14(x) = 1 + x + x^2 + x^3 + x^7
f16(x) = 1 + x + x^2 + x^5 + x^6 + x^7 + x^8 + x^9
f17(x) = 1 + x^3 + x^4 + x^5 + x^6 + x^7 + x^9
f20(x) = 1 + x^3 + x^9 + x^11
输入序列为:10011011000111010100
可以生成此序列的最优为 11 级线性反馈移位寄存器
该寄存器的连接多项式为:f(x) = 1 + x^3 + x^9 + x^11
$ python -u main.py -d 2 10011011000111010100
l(1)=1 f1(x) = 1 + x
l(1)=1 f2(x) = 1
l(2)=1 f3(x) = 1
l(3)=3 f4(x) = 1 + x^3
l(4)=3 f5(x) = 1 + x + x^3
l(5)=3 f6(x) = 1 + x + x^2 + x^3
l(6)=4 f7(x) = 1 + x + x^2
l(7)=4 f8(x) = 1 + x + x^2
l(8)=4 f9(x) = 1 + x + x^2
l(9)=6 f10(x) = 1 + x + x^2 + x^3 + x^4 + x^5 + x^6
l(10)=6 f11(x) = 1 + x^4 + x^5 + x^6
l(11)=6 f12(x) = 1 + x^2 + x^3 + x^5 + x^6
l(12)=7 f13(x) = 1 + x^2 + x^4 + x^6
l(13)=7 f14(x) = 1 + x + x^2 + x^3 + x^7
l(14)=7 f15(x) = 1 + x + x^2 + x^3 + x^7
l(15)=9 f16(x) = 1 + x + x^2 + x^5 + x^6 + x^7 + x^8 + x^9
l(16)=9 f17(x) = 1 + x^3 + x^4 + x^5 + x^6 + x^7 + x^9
l(17)=9 f18(x) = 1 + x^3 + x^4 + x^5 + x^6 + x^7 + x^9
l(18)=9 f19(x) = 1 + x^3 + x^4 + x^5 + x^6 + x^7 + x^9
l(19)=11 f20(x) = 1 + x^3 + x^9 + x^11
本格式用于本人提交作业的。
$ python main.py -d 3 10011011000111010100
n(0) = 0
f0(x) = 1
l0 = 0
n = 1
l(1)=1 f1(x) = 1 + x
n = 1 d(1) = 1 m = 0
l(1)=1 f2(x) = 1
n = 2 d(2) = 0 m = 0
l(2)=1 f3(x) = 1
n = 3 d(3) = 1 m = 3
l(3)=3 f4(x) = 1 + x^3
n = 4 d(4) = 1 m = 3
l(4)=3 f5(x) = 1 + x + x^3
n = 5 d(5) = 1 m = 3
l(5)=3 f6(x) = 1 + x + x^2 + x^3
n = 6 d(6) = 1 m = 6
l(6)=4 f7(x) = 1 + x + x^2
n = 7 d(7) = 0 m = 6
l(7)=4 f8(x) = 1 + x + x^2
n = 8 d(8) = 0 m = 6
l(8)=4 f9(x) = 1 + x + x^2
n = 9 d(9) = 1 m = 9
l(9)=6 f10(x) = 1 + x + x^2 + x^3 + x^4 + x^5 + x^6
n = 10 d(10) = 1 m = 9
l(10)=6 f11(x) = 1 + x^4 + x^5 + x^6
n = 11 d(11) = 1 m = 9
l(11)=6 f12(x) = 1 + x^2 + x^3 + x^5 + x^6
n = 12 d(12) = 1 m = 12
l(12)=7 f13(x) = 1 + x^2 + x^4 + x^6
n = 13 d(13) = 1 m = 12
l(13)=7 f14(x) = 1 + x + x^2 + x^3 + x^7
n = 14 d(14) = 0 m = 12
l(14)=7 f15(x) = 1 + x + x^2 + x^3 + x^7
n = 15 d(15) = 1 m = 15
l(15)=9 f16(x) = 1 + x + x^2 + x^5 + x^6 + x^7 + x^8 + x^9
n = 16 d(16) = 1 m = 15
l(16)=9 f17(x) = 1 + x^3 + x^4 + x^5 + x^6 + x^7 + x^9
n = 17 d(17) = 0 m = 15
l(17)=9 f18(x) = 1 + x^3 + x^4 + x^5 + x^6 + x^7 + x^9
n = 18 d(18) = 0 m = 15
l(18)=9 f19(x) = 1 + x^3 + x^4 + x^5 + x^6 + x^7 + x^9
n = 19 d(19) = 1 m = 19
l(19)=11 f20(x) = 1 + x^3 + x^9 + x^11
输入序列为:10011011000111010100
可以生成此序列的最优为 11 级线性反馈移位寄存器
该寄存器的连接多项式为:f(x) = 1 + x^3 + x^9 + x^11
- 英文模式