From 15aab663757938f90f5b20a3123c9c468c999bef Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Thu, 28 Nov 2024 04:32:15 +0500 Subject: [PATCH] minimum distance for 2BGA codes --- test/test_ecc_2bga.jl | 56 ++++++++++++++++++- ...stance_mixed_integer_linear_programming.jl | 29 ++++++---- 2 files changed, 73 insertions(+), 12 deletions(-) diff --git a/test/test_ecc_2bga.jl b/test/test_ecc_2bga.jl index 9b3f0a609..90505b03b 100644 --- a/test/test_ecc_2bga.jl +++ b/test/test_ecc_2bga.jl @@ -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) @@ -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])) @@ -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])) @@ -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])) @@ -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])) @@ -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])) @@ -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 diff --git a/test/test_ecc_code_distance_mixed_integer_linear_programming.jl b/test/test_ecc_code_distance_mixed_integer_linear_programming.jl index e74ee7a17..5fb893844 100644 --- a/test/test_ecc_code_distance_mixed_integer_linear_programming.jl +++ b/test/test_ecc_code_distance_mixed_integer_linear_programming.jl @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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