Skip to content

Commit

Permalink
minimum distance for 2BGA codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fe-r-oz committed Nov 27, 2024
1 parent bb3efdc commit 15aab66
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 12 deletions.
56 changes: 54 additions & 2 deletions test/test_ecc_2bga.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
@testitem "ECC 2BGA" begin
using Hecke
using Hecke: group_algebra, GF, abelian_group, gens
using QuantumClifford.ECC: two_block_group_algebra_codes, code_k, code_n
using JuMP
using GLPK
using Hecke: group_algebra, GF, abelian_group, gens, one
using QuantumClifford
using QuantumClifford.ECC: two_block_group_algebra_codes, code_k, code_n, parity_checks, parity_checks_x

include("test_ecc_util.jl") # minimum_distance

function get_hx_lx(c)
hx = stab_to_gf2(Stabilizer(parity_checks(c))[1:end÷2,:])
lx = stab_to_gf2(logicalxview(canonicalize!(MixedDestabilizer(parity_checks(c)))))
return hx, lx
end

function code_distance(hx, lx, k)
w_values = []
for i in 1:k
w = minimum_distance(hx, lx[i, :])
push!(w_values, w)
end
return round(Int, sum(w_values)/k)
end

@testset "Reproduce Table 2 lin2024quantum" begin
# codes taken from Table 2 of [lin2024quantum](@cite)
Expand All @@ -14,16 +34,22 @@
c = two_block_group_algebra_codes(A,B)
# [[16, 2, 4]] 2BGA code
@test code_n(c) == 16 && code_k(c) == 2
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 4
A = 1 + x
B = 1 + x + s + x^2 + s*x + x^3
c = two_block_group_algebra_codes(A,B)
# [[16, 4, 4]] 2BGA code
@test code_n(c) == 16 && code_k(c) == 4
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 4
A = 1 + s
B = 1 + x + s + x^2 + s*x + x^2
c = two_block_group_algebra_codes(A,B)
# [[16, 8, 2]] 2BGA code
@test code_n(c) == 16 && code_k(c) == 8
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 2

# m = 6
GA = group_algebra(GF(2), abelian_group([6,2]))
Expand All @@ -33,11 +59,15 @@
c = two_block_group_algebra_codes(A,B)
# [[24, 4, 5]] 2BGA code
@test code_n(c) == 24 && code_k(c) == 4
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 5
A = 1 + x^3
B = 1 + x^3 + s + x^4 + s*x^3 + x
c = two_block_group_algebra_codes(A,B)
# [[24, 12, 2]] 2BGA code
@test code_n(c) == 24 && code_k(c) == 12
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 2

# m = 8
GA = group_algebra(GF(2), abelian_group([8,2]))
Expand All @@ -47,11 +77,15 @@
c = two_block_group_algebra_codes(A,B)
# [[32, 8, 4]] 2BGA code
@test code_n(c) == 32 && code_k(c) == 8
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 4
A = 1 + s*x^4
B = 1 + s*x^7 + s*x^4 + x^6 + x^3 + s*x^2
c = two_block_group_algebra_codes(A,B)
# [[32, 16, 2]] 2BGA code
@test code_n(c) == 32 && code_k(c) == 16
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 2

# m = 10
GA = group_algebra(GF(2), abelian_group([10,2]))
Expand All @@ -61,16 +95,22 @@
c = two_block_group_algebra_codes(A,B)
# [[40, 4, 8]] 2BGA code
@test code_n(c) == 40 && code_k(c) == 4
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 8
A = 1 + x^6
B = 1 + x^5 + s + x^6 + x + s*x^2
c = two_block_group_algebra_codes(A,B)
# [[40, 8, 5]] 2BGA code
@test code_n(c) == 40 && code_k(c) == 8
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 5
A = 1 + x^5
B = 1 + x^5 + s + x^6 + s*x^5 + x
c = two_block_group_algebra_codes(A,B)
# [[40, 20, 2]] 2BGA code
@test code_n(c) == 40 && code_k(c) == 20
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 2

# m = 12
GA = group_algebra(GF(2), abelian_group([12,2]))
Expand All @@ -80,21 +120,29 @@
c = two_block_group_algebra_codes(A,B)
# [[48, 8, 6]] 2BGA code
@test code_n(c) == 48 && code_k(c) == 8
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 6
A = 1 + x^3
B = 1 + x^3 + s*x^6 + x^4 + s*x^9 + x^7
c = two_block_group_algebra_codes(A,B)
# [[48, 12, 4]] 2BGA code
@test code_n(c) == 48 && code_k(c) == 12
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 4
A = 1 + x^4
B = 1 + x^3 + s*x^6 + x^4 + x^7 + s*x^10
c = two_block_group_algebra_codes(A,B)
# [[48, 16, 3]] 2BGA code
@test code_n(c) == 48 && code_k(c) == 16
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 3
A = 1 + s*x^6
B = 1 + x^3 + s*x^6 + x^4 + s*x^9 + s*x^10
c = two_block_group_algebra_codes(A,B)
# [[48, 24, 2]] 2BGA code
@test code_n(c) == 48 && code_k(c) == 24
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 2

# m = 14
GA = group_algebra(GF(2), abelian_group([14,2]))
Expand All @@ -104,10 +152,14 @@
c = two_block_group_algebra_codes(A,B)
# [[56, 8, 7]] 2BGA code
@test code_n(c) == 56 && code_k(c) == 8
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 7
A = 1 + x^7
B = 1 + x^7 + s + x^8 + s*x^7 + x
c = two_block_group_algebra_codes(A,B)
# [[56, 28, 2]] 2BGA code
@test code_n(c) == 56 && code_k(c) == 28
hx, lx = get_hx_lx(c)
@test code_distance(hx, lx, code_k(c)) == 2
end
end
29 changes: 19 additions & 10 deletions test/test_ecc_code_distance_mixed_integer_linear_programming.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using GLPK
using Hecke: group_algebra, GF, abelian_group, gens, one
using QuantumClifford
using QuantumClifford.ECC: two_block_group_algebra_codes, code_k, code_n, parity_checks
using QuantumClifford.ECC: two_block_group_algebra_codes, code_k, code_n, parity_checks, parity_checks_x

include("test_ecc_util.jl") # minimum_distance

Expand All @@ -14,6 +14,15 @@
return hx, lx
end

function code_distance(hx, lx, k)
w_values = []
for i in 1:k
w = minimum_distance(hx, lx[i, :])
push!(w_values, w)
end
return round(Int, sum(w_values)/k)
end

@testset "Reproduce Table 3 bravyi2024high" begin
# [[72, 12, 6]]
l=6; m=6
Expand All @@ -24,7 +33,7 @@
c = two_block_group_algebra_codes(A,B)
hx, lx = get_hx_lx(c)
i = rand(1:code_k(c))
@test minimum_distance(hx, lx[i, :]) == 6
@test code_distance(hx, lx, code_k(c)) == 6

# [[90, 8, 10]]
l=15; m=3
Expand All @@ -35,7 +44,7 @@
c = two_block_group_algebra_codes(A,B)
hx, lx = get_hx_lx(c)
i = rand(1:code_k(c))
@test minimum_distance(hx, lx[i, :]) == 10
@test code_distance(hx, lx, code_k(c)) == 10

# [[108, 8, 10]]
l=9; m=6
Expand All @@ -46,7 +55,7 @@
c = two_block_group_algebra_codes(A,B)
hx, lx = get_hx_lx(c)
i = rand(1:code_k(c))
@test minimum_distance(hx, lx[i, :]) == 10
@test code_distance(hx, lx, code_k(c)) == 10
end

@testset "Reproduce Table 1 berthusen2024toward" begin
Expand All @@ -59,7 +68,7 @@
c = two_block_group_algebra_codes(A,B)
hx, lx = get_hx_lx(c)
i = rand(1:code_k(c))
@test minimum_distance(hx, lx[i, :]) == 6
@test code_distance(hx, lx, code_k(c)) == 6

# [[90, 8, 6]]
l=9; m=5
Expand All @@ -70,7 +79,7 @@
c = two_block_group_algebra_codes(A,B)
hx, lx = get_hx_lx(c)
i = rand(1:code_k(c))
@test minimum_distance(hx, lx[i, :]) == 6
@test code_distance(hx, lx, code_k(c)) == 6

# [[120, 8, 8]]
l=12; m=5
Expand All @@ -81,7 +90,7 @@
c = two_block_group_algebra_codes(A,B)
hx, lx = get_hx_lx(c)
i = rand(1:code_k(c))
@test minimum_distance(hx, lx[i, :]) == 8
@test code_distance(hx, lx, code_k(c)) == 8
end

@testset "Reproduce Table 1 wang2024coprime" begin
Expand All @@ -94,7 +103,7 @@
c = two_block_group_algebra_codes(A,B)
hx, lx = get_hx_lx(c)
i = rand(1:code_k(c))
@test minimum_distance(hx, lx[i, :]) == 6
@test code_distance(hx, lx, code_k(c)) == 6

# [[98, 6, 12]]
l=7; m=7
Expand All @@ -105,7 +114,7 @@
c = two_block_group_algebra_codes(A,B)
hx, lx = get_hx_lx(c)
i = rand(1:code_k(c))
@test minimum_distance(hx, lx[i, :]) == 12
@test code_distance(hx, lx, code_k(c)) == 12

# [[126, 8, 10]]
l=3; m=21
Expand All @@ -116,6 +125,6 @@
c = two_block_group_algebra_codes(A,B)
hx, lx = get_hx_lx(c)
i = rand(1:code_k(c))
@test minimum_distance(hx, lx[i, :]) == 10
@test code_distance(hx, lx, code_k(c)) == 10
end
end

0 comments on commit 15aab66

Please sign in to comment.