|
1 | | -@testitem "ECC BCH" begin |
| 1 | +@testitem "ECC BCH" tags=[:ecc] begin |
2 | 2 | using LinearAlgebra |
3 | 3 | using QuantumClifford.ECC |
4 | 4 | using QuantumClifford.ECC: AbstractECC, BCH, generator_polynomial |
5 | 5 | using Nemo: ZZ, residue_ring, matrix, finite_field, GF, minpoly, coeff, lcm, FqPolyRingElem, FqFieldElem, is_zero, degree, defining_polynomial, is_irreducible |
6 | | - using QuantumClifford.ECC.QECCore: code_k, code_n, distance, rate |
| 6 | + using QuantumClifford.ECC.QECCore: code_k, code_n, distance, rate |
7 | 7 |
|
8 | 8 | """ |
9 | | - - To prove that `t`-bit error correcting BCH code indeed has minimum distance of at least `2 * t + 1`, it is shown that no `2 * t` or fewer columns of its binary parity check matrix `H` sum to zero. A formal mathematical proof can be found on pages 168 and 169 of Ch6 of Error Control Coding by Lin, Shu and Costello, Daniel. |
| 9 | + - To prove that `t`-bit error correcting BCH code indeed has minimum distance of at least `2 * t + 1`, it is shown that no `2 * t` or fewer columns of its binary parity check matrix `H` sum to zero. A formal mathematical proof can be found on pages 168 and 169 of Ch6 of Error Control Coding by Lin, Shu and Costello, Daniel. |
10 | 10 | - The parameter `2 * t + 1` is usually called the designed distance of the `t`-bit error correcting BCH code. |
11 | 11 | """ |
12 | 12 | function check_designed_distance(matrix, t) |
|
37 | 37 | @test code_k(BCH(m, t)) == n - degree(generator_polynomial(BCH(m, t))) |
38 | 38 | # BCH code is cyclic as its generator polynomial, `g(x)` divides `xⁿ - 1`, so `mod (xⁿ - 1, g(x))` = 0. |
39 | 39 | gx = generator_polynomial(BCH(m, t)) |
40 | | - GF2x, x = GF(2)["x"] |
| 40 | + GF2x, x = GF(2)["x"] |
41 | 41 | @test mod(x ^ n - 1, gx) == 0 |
42 | 42 | end |
43 | 43 | end |
|
61 | 61 | @test generator_polynomial(BCH(4, 2)) == x ^ 8 + x ^ 7 + x ^ 6 + x ^ 4 + 1 |
62 | 62 | @test generator_polynomial(BCH(4, 3)) == x ^ 10 + x ^ 8 + x ^ 5 + x ^ 4 + x ^ 2 + x + 1 |
63 | 63 |
|
64 | | - # Nemo.jl uses [Conway polynomial](https://en.wikipedia.org/wiki/Conway_polynomial_(finite_fields)), a standard way to represent the primitive polynomial for finite Galois fields `GF(pᵐ)` of degree `m`, where `p` is a prime number. |
| 64 | + # Nemo.jl uses [Conway polynomial](https://en.wikipedia.org/wiki/Conway_polynomial_(finite_fields)), a standard way to represent the primitive polynomial for finite Galois fields `GF(pᵐ)` of degree `m`, where `p` is a prime number. |
65 | 65 | # The `GF(2⁶)`'s Conway polynomial is `p(z) = z⁶ + z⁴ + z³ + z + 1`. In contrast, the polynomial given in https://web.ntpu.edu.tw/~yshan/BCH_code.pdf is `p(z) = z⁶ + z + 1`. Because both polynomials are irreducible, they are also primitive polynomials for `GF(2⁶)`. |
66 | 66 |
|
67 | 67 | test_cases = [(6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 10), (6, 11), (6, 13), (6, 15)] |
68 | 68 | @test defining_polynomial(GF2x, GF2⁶) == x ^ 6 + x ^ 4 + x ^ 3 + x + 1 |
69 | | - @test is_irreducible(defining_polynomial(GF2x, GF2⁶)) == true |
| 69 | + @test is_irreducible(defining_polynomial(GF2x, GF2⁶)) == true |
70 | 70 | for i in 1:length(test_cases) |
71 | 71 | m, t = test_cases[i] |
72 | 72 | if t == 1 |
|
0 commit comments