Skip to content

Commit

Permalink
further simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
Fe-r-oz committed Nov 5, 2024
1 parent 8b5813f commit 3082dbd
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 85 deletions.
3 changes: 1 addition & 2 deletions ext/QuantumCliffordHeckeExt/QuantumCliffordHeckeExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import Nemo: characteristic, matrix_repr, GF, ZZ, lift

import QuantumClifford.ECC: AbstractECC, CSS, ClassicalCode,
hgp, code_k, code_n, code_s, iscss, parity_checks, parity_checks_x, parity_checks_z, parity_checks_xz,
two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes, check_repr_commutation_relation,
bivariate_bicycle_codes
two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes, check_repr_commutation_relation

include("util.jl")
include("types.jl")
Expand Down
71 changes: 32 additions & 39 deletions ext/QuantumCliffordHeckeExt/lifted_product.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,36 @@ julia> code_n(c), code_k(c)
(56, 28)
```
See also: [`LPCode`](@ref), [`generalized_bicycle_codes`](@ref), [`bicycle_codes`](@ref), [`bivariate_bicycle_codes`](@ref)
# Examples of 2BGA Code subfamilies
Bivariate Bicycle codes are a class of Abelian 2BGA codes formed by the direct product
of two cyclic groups `ℤₗ × ℤₘ`. The parameters `l` and `m` represent the orders of the
first and second cyclic groups, respectively.
The ECC Zoo has an [entry for this family](https://errorcorrectionzoo.org/c/qcga).
A [[756, 16, ≤ 34]] code from Table 3 of [bravyi2024high](@cite).
```jldoctest
julia> import Hecke: group_algebra, GF, abelian_group, gens; # hide
julia> l=21; m=18;
julia> GA = group_algebra(GF(2), abelian_group([l, m]));
julia> x, y = gens(GA);
julia> A = x^3 + y^10 + y^17;
julia> B = y^5 + x^3 + x^19;
julia> c = two_block_group_algebra_codes(A,B);
julia> code_n(c), code_k(c)
(756, 16)
```
See also: [`LPCode`](@ref), [`generalized_bicycle_codes`](@ref), [`bicycle_codes`](@ref).
"""
function two_block_group_algebra_codes(a::GroupAlgebraElem, b::GroupAlgebraElem)
LPCode([a;;], [b;;])
Expand All @@ -186,7 +215,7 @@ Generalized bicycle codes, which are a special case of 2GBA codes (and therefore
Here the group is chosen as the cyclic group of order `l`,
and the base matrices `a` and `b` are the sum of the group algebra elements corresponding to the shifts `a_shifts` and `b_shifts`.
See also: [`two_block_group_algebra_codes`](@ref), [`bicycle_codes`](@ref), [`bivariate_bicycle_codes`](@ref)
See also: [`two_block_group_algebra_codes`](@ref), [`bicycle_codes`](@ref).
A [[254, 28, 14 ≤ d ≤ 20]] code from (A1) in Appendix B of [panteleev2021degenerate](@cite).
Expand All @@ -209,46 +238,10 @@ Bicycle codes are a special case of generalized bicycle codes,
where `a` and `b` are conjugate to each other.
The order of the cyclic group is `l`, and the shifts `a_shifts` and `b_shifts` are reverse to each other.
See also: [`two_block_group_algebra_codes`](@ref), [`generalized_bicycle_codes`](@ref), [`bivariate_bicycle_codes`](@ref)
See also: [`two_block_group_algebra_codes`](@ref), [`generalized_bicycle_codes`](@ref).
""" # TODO doctest example
function bicycle_codes(a_shifts::Array{Int}, l::Int)
GA = group_algebra(GF(2), abelian_group(l))
a = sum(GA[n÷l+1] for n in a_shifts)
two_block_group_algebra_codes(a, group_algebra_conj(a))
end

"""
Bivariate Bicycle codes are a class of Abelian 2BGA codes formed by the direct product
of two cyclic groups `ℤₗ × ℤₘ`. The parameters `l` and `m` represent the orders of the
first and second cyclic groups, respectively.
The ECC Zoo has an [entry for this family](https://errorcorrectionzoo.org/c/qcga).
See also: [`two_block_group_algebra_codes`](@ref), [`generalized_bicycle_codes`](@ref),
[`bicycle_codes`](@ref), [`LPCode`](@ref)
A [[756, 16, ≤ 34]] code from Table 3 of [bravyi2024high](@cite).
```jldoctest
julia> import Hecke: group_algebra, GF, abelian_group, gens; # hide
julia> l=21; m=18;
julia> GA = group_algebra(GF(2), abelian_group([l, m]));
julia> x, y = gens(GA);
julia> A = x^3 + y^10 + y^17;
julia> B = y^5 + x^3 + x^19;
julia> c = bivariate_bicycle_codes(A,B);
julia> code_n(c), code_k(c)
(756, 16)
```
"""
function bivariate_bicycle_codes(A::GroupAlgebraElem, B::GroupAlgebraElem)
c = two_block_group_algebra_codes(A,B)
return c
end
1 change: 0 additions & 1 deletion src/ecc/ECC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export parity_checks, parity_checks_x, parity_checks_z, iscss,
Shor9, Steane7, Cleve8, Perfect5, Bitflip3,
Toric, Gottesman, Surface, Concat, CircuitCode, QuantumReedMuller,
LPCode, two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes,
bivariate_bicycle_codes,
random_brickwork_circuit_code, random_all_to_all_circuit_code,
evaluate_decoder,
CommutationCheckECCSetup, NaiveSyndromeECCSetup, ShorSyndromeECCSetup,
Expand Down
3 changes: 0 additions & 3 deletions src/ecc/codes/lifted_product.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ function generalized_bicycle_codes end

"""Implemented in a package extension with Hecke."""
function bicycle_codes end

"""Implemented in a package extension with Hecke."""
function bivariate_bicycle_codes end
7 changes: 4 additions & 3 deletions test/test_ecc_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,30 @@ A[LinearAlgebra.diagind(A, 5)] .= GA(1)
B = reshape([1 + x + x^6], (1, 1))
push!(other_lifted_product_codes, LPCode(A, B))

# Bivariate Bicycle codes
# A [[72, 12, 6]] code from Table 3 of [bravyi2024high](@cite).
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
bb1 = bivariate_bicycle_codes(A,B)
bb1 = two_block_group_algebra_codes(A,B)

# A [[90, 8, 10]] code from Table 3 of [bravyi2024high](@cite).
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
bb2 = bivariate_bicycle_codes(A,B)
bb2 = two_block_group_algebra_codes(A,B)

# A [[360, 12, ≤ 24]] code from Table 3 of [bravyi2024high](@cite).
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
bb3 = bivariate_bicycle_codes(A,B)
bb3 = two_block_group_algebra_codes(A,B)

test_bb_codes = [bb1, bb2, bb3]

Expand Down
74 changes: 37 additions & 37 deletions test/test_ecc_bivaraite_bicycle_as_twobga.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@testitem "ECC Bivaraite Bicycle as 2BGA" begin
using Hecke
using Hecke: group_algebra, GF, abelian_group, gens, one
using QuantumClifford.ECC: bivariate_bicycle_codes, code_k, code_n
using QuantumClifford.ECC: two_block_group_algebra_codes, code_k, code_n

@testset "Reproduce Table 3 bravyi2024high" begin
# [[72, 12, 6]]
Expand All @@ -10,62 +10,62 @@
x, y = gens(GA)
A = x^3 + y + y^2
B = y^3 + x + x^2
c = bivariate_bicycle_codes(A,B)
@test code_n(c) == 72 && code_k(c) == 12
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 90 && code_k(c) == 8
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 108 && code_k(c) == 8
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 144 && code_k(c) == 12
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 288 && code_k(c) == 12
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 360 && code_k(c) == 12
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 756 && code_k(c) == 16
c = two_block_group_algebra_codes(A,B)
@test code_n(c) == 756 && code_k(c) == 16
end

@testset "Reproduce Table 1 berthusen2024toward" begin
Expand All @@ -75,44 +75,44 @@
x, y = gens(GA)
A = x^9 + y + y^2
B = 1 + x + x^11
c = bivariate_bicycle_codes(A,B)
@test code_n(c) == 72 && code_k(c) == 8
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 90 && code_k(c) == 8
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 120 && code_k(c) == 8
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 150 && code_k(c) == 8
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 196 && code_k(c) == 12
c = two_block_group_algebra_codes(A,B)
@test code_n(c) == 196 && code_k(c) == 12
end

@testset "Reproduce Table 1 wang2024coprime" begin
Expand All @@ -122,52 +122,52 @@
x, y = gens(GA)
A = 1 + y^2 + y^4
B = y^3 + x + x^2
c = bivariate_bicycle_codes(A,B)
@test code_n(c) == 54 && code_k(c) == 8
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 98 && code_k(c) == 6
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 126 && code_k(c) == 8
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 150 && code_k(c) == 16
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 162 && code_k(c) == 8
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 = bivariate_bicycle_codes(A,B)
@test code_n(c) == 180 && code_k(c) == 8
c = two_block_group_algebra_codes(A,B)
@test code_n(c) == 180 && code_k(c) == 8
end
end

0 comments on commit 3082dbd

Please sign in to comment.