From 7037b764bc854bdb07b0f991392fd08817772408 Mon Sep 17 00:00:00 2001 From: Benzillaist Date: Tue, 19 Nov 2024 05:44:14 -0500 Subject: [PATCH] Re-enabled tests, cleaned up code, and added description to bicycle_set_gen Made some small changes to the structure of the code, but primarily edited bicycle_set_gen. Added information about how the method works, what problems one can encounter, and what it returns. --- docs/src/references.bib | 6 +- src/ecc/codes/simple_sparse_codes.jl | 50 ++- test/test_ecc_bivaraite_bicycle_as_twobga.jl | 346 +++++++++---------- 3 files changed, 208 insertions(+), 194 deletions(-) diff --git a/docs/src/references.bib b/docs/src/references.bib index c39e03518..58e106dbb 100644 --- a/docs/src/references.bib +++ b/docs/src/references.bib @@ -419,13 +419,13 @@ @article{RevModPhys.87.307 } @misc{goodenough2024bipartiteentanglementnoisystabilizer, - title={Bipartite entanglement of noisy stabilizer states through the lens of stabilizer codes}, + title={Bipartite entanglement of noisy stabilizer states through the lens of stabilizer codes}, author={Kenneth Goodenough and Aqil Sajjad and Eneet Kaur and Saikat Guha and Don Towsley}, year={2024}, eprint={2406.02427}, archivePrefix={arXiv}, primaryClass={quant-ph}, - url={https://arxiv.org/abs/2406.02427}, + url={https://arxiv.org/abs/2406.02427}, } @article{panteleev2021degenerate, @@ -532,7 +532,7 @@ @article{wang2024coprime } @misc{voss2024multivariatebicyclecodes, - title={Multivariate Bicycle Codes}, + title={Multivariate Bicycle Codes}, author={Lukas Voss and Sim Jian Xian and Tobias Haug and Kishor Bharti}, year={2024}, eprint={2406.19151}, diff --git a/src/ecc/codes/simple_sparse_codes.jl b/src/ecc/codes/simple_sparse_codes.jl index 1c66bcc20..ea463cda3 100644 --- a/src/ecc/codes/simple_sparse_codes.jl +++ b/src/ecc/codes/simple_sparse_codes.jl @@ -46,7 +46,6 @@ function parity_checks(b::Bicycle) bs = bicycle_set_gen(Int(n/2)) bsc = circ_to_bicycle_h0(bs, Int(n/2)) while size(bsc)[1] > m/2 - print(bsc) bsc = reduce_bicycle(bsc) end return parity_checks(CSS(bsc, bsc)) @@ -98,12 +97,12 @@ Typical usage: julia> reduce_bicycle(circ_to_bicycle_h0([1, 2, 4], 7)) 6×14 Matrix{Bool}: - 0 0 1 1 0 1 0 1 0 0 0 1 0 1 - 0 0 0 1 1 0 1 1 1 0 0 0 1 0 - 1 0 0 0 1 1 0 0 1 1 0 0 0 1 - 0 1 0 0 0 1 1 1 0 1 1 0 0 0 - 1 0 1 0 0 0 1 0 1 0 1 1 0 0 - 1 1 0 1 0 0 0 0 0 1 0 1 1 0 + 1 1 0 1 0 0 0 1 0 0 0 1 0 1 + 0 1 1 0 1 0 0 1 1 0 0 0 1 0 + 0 0 0 1 1 0 1 1 0 1 1 0 0 0 + 1 0 0 0 1 1 0 0 1 0 1 1 0 0 + 0 1 0 0 0 1 1 0 0 1 0 1 1 0 + 1 0 1 0 0 0 1 0 0 0 1 0 1 1 ``` """ @@ -130,13 +129,13 @@ For example: julia> circ_to_bicycle_h0([1, 2, 4], 7) 7×14 Matrix{Bool}: - 0 1 1 0 1 0 0 0 0 0 1 0 1 1 - 0 0 1 1 0 1 0 1 0 0 0 1 0 1 - 0 0 0 1 1 0 1 1 1 0 0 0 1 0 - 1 0 0 0 1 1 0 0 1 1 0 0 0 1 - 0 1 0 0 0 1 1 1 0 1 1 0 0 0 - 1 0 1 0 0 0 1 0 1 0 1 1 0 0 - 1 1 0 1 0 0 0 0 0 1 0 1 1 0 + 1 1 0 1 0 0 0 1 0 0 0 1 0 1 + 0 1 1 0 1 0 0 1 1 0 0 0 1 0 + 0 0 1 1 0 1 0 0 1 1 0 0 0 1 + 0 0 0 1 1 0 1 1 0 1 1 0 0 0 + 1 0 0 0 1 1 0 0 1 0 1 1 0 0 + 0 1 0 0 0 1 1 0 0 1 0 1 1 0 + 1 0 1 0 0 0 1 0 0 0 1 0 1 1 ``` See [mackay2004sparse](@cite) for more details @@ -146,7 +145,7 @@ function circ_to_bicycle_h0(circ_indices, n::Int) circ_matrix = Matrix{Bool}(undef, n, n) comp_matrix = Matrix{Bool}(undef, n, 2*n) for i = 1:n - if Int(i-1) in circ_indices + if Int(i) in circ_indices circ_arr[i] = true else circ_arr[i] = false @@ -240,11 +239,26 @@ function circ_to_unicycle_h0(circ_indices::Vector{Int}, n::Int) return comp_matrix end -"""Attempts to generate a list of indices to be used in a bicycle code using a search method given a matrix width (N)""" +""" +Generates a list of indices to be used in a bicycle code using a search method given a number of qubits (N). This algirithm finds indicies which have the property that no 2 differences between elements occurs more than once. The differences can also loop over the end of the array. For example, the method will never return the indices 1, 3, and 5, as the difference '2' occurs twice. Occurrences are: 3-1 = 2 and 5-3 = 2. + +Note: This algorithm can, but is not guaranteed, to find the optimal sets of indices for certain numbers of qubits. For example N = 13 will give you a perfect difference set, the optimal set of indices. We know this is the optimal set as there are no ways to increase the number of unique differences because the number of unique distances has been maximized per definition of a perfect difference set. Optimal indices can be found via a Monte Carlo search or brute force method. Generally, one does not need to worry about small numbers of missing differences as the function often returns the optimal set, but it is hard to prove so for larger qubit numbers. + +This algorithm find the indices by iterating a value 'i' over 1 to N and doing the following for each index: The algorithm adds 'i' to the set of indices, checks if it violates the difference set property, keeps it in the set if it does not violate the afformentioned property, and otherwise removes. + +```jldoctest bicycle_set_gen +julia> bicycle_set_gen(13) +4-element Vector{Int64}: + 1 + 2 + 4 + 10 + +``` +""" function bicycle_set_gen(N::Int) circ_arr = Int[0] diff_arr = Int[] - circ_arr[1] = 0 # test new elements for add_i = (circ_arr[end] + 1):N - 1 valid = true @@ -280,5 +294,5 @@ function bicycle_set_gen(N::Int) diff_arr = copy(temp_diff_arr) end end - return circ_arr + return circ_arr .+ 1 end \ No newline at end of file diff --git a/test/test_ecc_bivaraite_bicycle_as_twobga.jl b/test/test_ecc_bivaraite_bicycle_as_twobga.jl index 2486421f0..ffeac975a 100644 --- a/test/test_ecc_bivaraite_bicycle_as_twobga.jl +++ b/test/test_ecc_bivaraite_bicycle_as_twobga.jl @@ -1,173 +1,173 @@ -# @testitem "ECC Bivaraite Bicycle as 2BGA" begin -# using Hecke -# using Hecke: group_algebra, GF, abelian_group, gens, one -# using QuantumClifford.ECC: two_block_group_algebra_codes, code_k, code_n - -# @testset "Reproduce Table 3 bravyi2024high" begin -# # [[72, 12, 6]] -# l=6; m=6 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^3 + y + y^2 -# B = y^3 + x + x^2 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 72 && code_k(c) == 12 - -# # [[90, 8, 10]] -# l=15; m=3 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^9 + y + y^2 -# B = 1 + x^2 + x^7 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 90 && code_k(c) == 8 - -# # [[108, 8, 10]] -# l=9; m=6 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^3 + y + y^2 -# B = y^3 + x + x^2 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 108 && code_k(c) == 8 - -# # [[144, 12, 12]] -# l=12; m=6 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^3 + y + y^2 -# B = y^3 + x + x^2 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 144 && code_k(c) == 12 - -# # [[288, 12, 12]] -# l=12; m=12 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^3 + y^2 + y^7 -# B = y^3 + x + x^2 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 288 && code_k(c) == 12 - -# # [[360, 12, ≤ 24]] -# l=30; m=6 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^9 + y + y^2 -# B = y^3 + x^25 + x^26 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 360 && code_k(c) == 12 - -# # [[756, 16, ≤ 34]] -# l=21; m=18 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^3 + y^10 + y^17 -# B = y^5 + x^3 + x^19 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 756 && code_k(c) == 16 -# end - -# @testset "Reproduce Table 1 berthusen2024toward" begin -# # [[72, 8, 6]] -# l=12; m=3 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^9 + y + y^2 -# B = 1 + x + x^11 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 72 && code_k(c) == 8 - -# # [[90, 8, 6]] -# l=9; m=5 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^8 + y^4 + y -# B = y^5 + x^8 + x^7 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 90 && code_k(c) == 8 - -# # [[120, 8, 8]] -# l=12; m=5 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^10 + y^4 + y -# B = 1 + x + x^2 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 120 && code_k(c) == 8 - -# # [[150, 8, 8]] -# l=15; m=5 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^5 + y^2 + y^3 -# B = y^2 + x^7 + x^6 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 150 && code_k(c) == 8 - -# # [[196, 12, 8]] -# l=14; m=7 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^6 + y^5 + y^6 -# B = 1 + x^4 + x^13 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 196 && code_k(c) == 12 -# end - -# @testset "Reproduce Table 1 wang2024coprime" begin -# # [[54, 8, 6]] -# l=3; m=9 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = 1 + y^2 + y^4 -# B = y^3 + x + x^2 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 54 && code_k(c) == 8 - -# # [[98, 6, 12]] -# l=7; m=7 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^3 + y^5 + y^6 -# B = y^2 + x^3 + x^5 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 98 && code_k(c) == 6 - -# # [[126, 8, 10]] -# l=3; m=21 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = 1 + y^2 + y^10 -# B = y^3 + x + x^2 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 126 && code_k(c) == 8 - -# # [[150, 16, 8]] -# l=5; m=15 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = 1 + y^6 + y^8 -# B = y^5 + x + x^4 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 150 && code_k(c) == 16 - -# # [[162, 8, 14]] -# l=3; m=27 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = 1 + y^10 + y^14 -# B = y^12 + x + x^2 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 162 && code_k(c) == 8 - -# # [[180, 8, 16]] -# l=6; m=15 -# GA = group_algebra(GF(2), abelian_group([l, m])) -# x, y = gens(GA) -# A = x^3 + y + y^2 -# B = y^6 + x^4 + x^5 -# c = two_block_group_algebra_codes(A,B) -# @test code_n(c) == 180 && code_k(c) == 8 -# end -# end +@testitem "ECC Bivaraite Bicycle as 2BGA" begin + using Hecke + using Hecke: group_algebra, GF, abelian_group, gens, one + using QuantumClifford.ECC: two_block_group_algebra_codes, code_k, code_n + + @testset "Reproduce Table 3 bravyi2024high" begin + # [[72, 12, 6]] + l=6; m=6 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^3 + y + y^2 + B = y^3 + x + x^2 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 72 && code_k(c) == 12 + + # [[90, 8, 10]] + l=15; m=3 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^9 + y + y^2 + B = 1 + x^2 + x^7 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 90 && code_k(c) == 8 + + # [[108, 8, 10]] + l=9; m=6 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^3 + y + y^2 + B = y^3 + x + x^2 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 108 && code_k(c) == 8 + + # [[144, 12, 12]] + l=12; m=6 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^3 + y + y^2 + B = y^3 + x + x^2 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 144 && code_k(c) == 12 + + # [[288, 12, 12]] + l=12; m=12 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^3 + y^2 + y^7 + B = y^3 + x + x^2 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 288 && code_k(c) == 12 + + # [[360, 12, ≤ 24]] + l=30; m=6 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^9 + y + y^2 + B = y^3 + x^25 + x^26 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 360 && code_k(c) == 12 + + # [[756, 16, ≤ 34]] + l=21; m=18 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^3 + y^10 + y^17 + B = y^5 + x^3 + x^19 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 756 && code_k(c) == 16 + end + + @testset "Reproduce Table 1 berthusen2024toward" begin + # [[72, 8, 6]] + l=12; m=3 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^9 + y + y^2 + B = 1 + x + x^11 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 72 && code_k(c) == 8 + + # [[90, 8, 6]] + l=9; m=5 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^8 + y^4 + y + B = y^5 + x^8 + x^7 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 90 && code_k(c) == 8 + + # [[120, 8, 8]] + l=12; m=5 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^10 + y^4 + y + B = 1 + x + x^2 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 120 && code_k(c) == 8 + + # [[150, 8, 8]] + l=15; m=5 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^5 + y^2 + y^3 + B = y^2 + x^7 + x^6 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 150 && code_k(c) == 8 + + # [[196, 12, 8]] + l=14; m=7 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^6 + y^5 + y^6 + B = 1 + x^4 + x^13 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 196 && code_k(c) == 12 + end + + @testset "Reproduce Table 1 wang2024coprime" begin + # [[54, 8, 6]] + l=3; m=9 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = 1 + y^2 + y^4 + B = y^3 + x + x^2 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 54 && code_k(c) == 8 + + # [[98, 6, 12]] + l=7; m=7 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^3 + y^5 + y^6 + B = y^2 + x^3 + x^5 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 98 && code_k(c) == 6 + + # [[126, 8, 10]] + l=3; m=21 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = 1 + y^2 + y^10 + B = y^3 + x + x^2 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 126 && code_k(c) == 8 + + # [[150, 16, 8]] + l=5; m=15 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = 1 + y^6 + y^8 + B = y^5 + x + x^4 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 150 && code_k(c) == 16 + + # [[162, 8, 14]] + l=3; m=27 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = 1 + y^10 + y^14 + B = y^12 + x + x^2 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 162 && code_k(c) == 8 + + # [[180, 8, 16]] + l=6; m=15 + GA = group_algebra(GF(2), abelian_group([l, m])) + x, y = gens(GA) + A = x^3 + y + y^2 + B = y^6 + x^4 + x^5 + c = two_block_group_algebra_codes(A,B) + @test code_n(c) == 180 && code_k(c) == 8 + end +end