From 5eaba44c14e6d04d3dc99ee7a3b33ad7bc2453c2 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sat, 12 Oct 2024 11:15:34 +0500 Subject: [PATCH 01/12] fix doc build, misc bugs and add doctests --- docs/Project.toml | 10 +++ src/Quantum/product_codes.jl | 123 +++++++++++++++++++++++++++++ test/Quantum/product_codes_test.jl | 8 +- 3 files changed, 138 insertions(+), 3 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index 99bc958..2a69570 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,15 @@ [deps] BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232" +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" CodingTheory = "7ca085cf-10e4-43da-ad7d-8f62f68877b3" +DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" +Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244" +Hecke = "3e1990a7-5d81-5526-99ce-9ba3ff248f21" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" +Oscar = "f1435218-dba5-11e9-1e4d-f1a5fab5fc13" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/src/Quantum/product_codes.jl b/src/Quantum/product_codes.jl index 187c9f1..a35d0e5 100644 --- a/src/Quantum/product_codes.jl +++ b/src/Quantum/product_codes.jl @@ -12,6 +12,27 @@ HypergraphProductCode(A::CTMatrixTypes, B::CTMatrixTypes; char_vec::Union{Vector{zzModRingElem}, Missing}= missing, logs_alg::Symbol = :stnd_frm) Return the hypergraph product code of matrices `A` and `B`. + +# Example + +```jldoctest +[1922, 50, 16]] Hypergraph Product Code from Appendix B, Example C1 of [panteleev2021degenerate](@cite). + +julia> F, x = polynomial_ring(Oscar.Nemo.Native.GF(2), :x); + +julia> l = 31; + +julia> R, = residue_ring(F, x^l -1); + +julia> h = R(1 + x^2 + x^5); + +julia> A = residue_polynomial_to_circulant_matrix(h); + +julia> code = HypergraphProductCode(A, A); + +julia> length(code), dimension(code) +(1922, 50) +``` """ function HypergraphProductCode(A::CTMatrixTypes, B::CTMatrixTypes; char_vec::Union{Vector{zzModRingElem}, Missing} = missing, logs_alg::Symbol = :stnd_frm) @@ -258,6 +279,29 @@ end GeneralizedBicycleCode(A::CTMatrixTypes, B::CTMatrixTypes; char_vec::Union{Vector{zzModRingElem}, Missing} = missing, logs_alg::Symbol = :stnd_frm) Return the generealized bicycle code given by `A` and `B`. + +# Example + +[[254, 28, 14 ≤ d ≤ 20]] Generalized Bicycle Code from Appendix B, Example A1 of [panteleev2021degenerate](@cite). + +```jldoctest +julia> F = Oscar.Nemo.Native.GF(2); + +julia> S, x = polynomial_ring(F, :x); + +julia> l = 127; + +julia> R, _ = residue_ring(S, x^l - 1); + +julia> a = 1 + x^15 + x^20 + x^28 + x^66; + +julia> b = 1 + x^58 + x^59 + x^100 + x^121; + +julia> code = GeneralizedBicycleCode(R(a), R(b)); + +julia> length(code), dimension(code) +(254, 28) +``` """ function GeneralizedBicycleCode(A::T, B::T; char_vec::Union{Vector{zzModRingElem}, Missing} = missing, logs_alg::Symbol = :stnd_frm) where T <: CTMatrixTypes @@ -508,6 +552,39 @@ end LiftedProductCode(A::MatElem{T}, B::MatElem{T}; char_vec::Union{Vector{zzModRingElem}, Missing} = missing, logs_alg::Symbol = :stnd_frm) where T <: Union{ResElem, CTGroupAlgebra} Return the lifted product code given by the matrices `A` and `B`. + +# Example + +[[882, 24, 18 ≤ d ≤ 24]] Lifted Product Code from Appendix B, Example B1 of [panteleev2021degenerate](@cite). + +```jldoctest +julia> F = Oscar.Nemo.Native.GF(2); + +julia> S, x = polynomial_ring(F, :x) +(Univariate polynomial ring in x over F, x) + +julia> l = 63; + +julia> R, _ = residue_ring(S, x^l - 1); + +julia> A = matrix(R, 7, 7, + [x^27, 0 , 0 , 0 , 0 , 1 , x^54, + x^54, x^27, 0 , 0 , 0 , 0 , 1 , + 1 , x^54, x^27, 0 , 0 , 0 , 0 , + 0 , 1 , x^54, x^27, 0 , 0 , 0 , + 0 , 0 , 1 , x^54, x^27, 0 , 0 , + 0 , 0 , 0 , 1 , x^54, x^27, 0 , + 0 , 0 , 0 , 0 , 1 , x^54, x^27]); + +julia> b = R(1 + x + x^6); + +julia> code = LiftedProductCode(A, b); +┌ Warning: Commutativity of A and b required but not yet enforced. +└ @ CodingTheory ~/Desktop/ct/doctests/CodingTheory/src/Quantum/product_codes.jl:340 + +julia> length(code), dimension(code) +(882, 24) +``` """ function LiftedProductCode(A::MatElem{T}, B::MatElem{T}; char_vec::Union{Vector{zzModRingElem}, Missing} = missing, logs_alg::Symbol = :stnd_frm) where T <: Union{ResElem, CTGroupAlgebra} @@ -894,6 +971,29 @@ Return the bivariate bicycle code defined by the residue ring elements `a` and ` # Note - This is defined in https://arxiv.org/pdf/2308.07915 + +# Example + +[[360, 12, ≤24]] Bivariate Bicycle Code from Table 3 of [bravyi2024high](@cite). + +```jldoctest +julia> using CodingTheory, Oscar; + +julia> S, (x, y) = polynomial_ring(Oscar.Nemo.Native.GF(2), [:x, :y]); + +julia> l = 30; m = 6; + +julia> R, _ = quo(S, ideal(S, [x^l - 1, y^m - 1])); + +julia> a = R(x^9 + y + y^2); + +julia> b = R(y^3 + x^25 + x^26); + +julia> code = BivariateBicycleCode(a, b); + +julia> length(code), dimension(code) +(360, 12) +``` """ function BivariateBicycleCode(a::T, b::T) where T <: Union{MPolyQuoRingElem{FqMPolyRingElem}, MPolyQuoRingElem{fpMPolyRingElem}} R = parent(a) @@ -954,6 +1054,29 @@ Return the coprime bivariate bicycle code defined by the residue ring elements ` # Note - This is defined in https://arxiv.org/pdf/2408.10001v1. + +# Example + +[126, 12, 10]] Coprime Bivariate Bicycle Code from Table 2 of [wang2024coprime](@cite). + +```jldoctest +julia> using CodingTheory, Oscar; + +julia> S, (P) = polynomial_ring(Oscar.Nemo.Native.GF(2), [:P]); + +julia> l = 7; m = 9; + +julia> R, _ = quo(S, ideal(S, [P[1]^(l*m)])); + +julia> a = R(1 + P[1] + P[1]^58); + +julia> b = R(P[1]^3 + P[1]^16 + P[1]^44); + +julia> code = CoprimeBivariateBicycleCode(a, b); + +julia> length(code), dimension(code) +(126, 12) +``` """ function CoprimeBivariateBicycleCode(a::T, b::T) where T <: Union{MPolyQuoRingElem{FqMPolyRingElem}, MPolyQuoRingElem{fpMPolyRingElem}} R = parent(a) diff --git a/test/Quantum/product_codes_test.jl b/test/Quantum/product_codes_test.jl index 0490d8d..c4864a5 100644 --- a/test/Quantum/product_codes_test.jl +++ b/test/Quantum/product_codes_test.jl @@ -198,10 +198,9 @@ # takes awhile to run # Example C2 - F = Oscar.Nemo.Native.GF(2) - S, x = polynomial_ring(F, :x) + F, x = polynomial_ring(Oscar.Nemo.Native.GF(2), :x) l = 31 - R = ResidueRing(S, x^l - 1) + R, = residue_ring(F, x^l -1) h = R(1 + x^2 + x^5) A = residue_polynomial_to_circulant_matrix(h) Q = HypergraphProductCode(A, A) @@ -606,7 +605,9 @@ @test length(Q) == 196 @test dimension(Q) == 12 @test_broken minimum_distance(S) == 8 + end + @testset "CoprimeBivariateBicycleCode" begin # Coprime Bivariate Bicycle codes # Table 2 of https://arxiv.org/pdf/2408.10001v1 # [[30, 4, 6]] @@ -664,4 +665,5 @@ @test length(Q) == 126 @test dimension(Q) == 12 @test_broken minimum_distance(Q) == 10 + end end From 23a916b0b03a622b5b672979a6456e81a54405d5 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sat, 12 Oct 2024 13:14:56 +0500 Subject: [PATCH 02/12] fix bug in BiasTailoredLiftedProductCode and add its tests, doctests --- src/Quantum/product_codes.jl | 39 +++++++++++++++++++++++++++--- test/Quantum/product_codes_test.jl | 35 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/src/Quantum/product_codes.jl b/src/Quantum/product_codes.jl index a35d0e5..6c76978 100644 --- a/src/Quantum/product_codes.jl +++ b/src/Quantum/product_codes.jl @@ -560,8 +560,7 @@ Return the lifted product code given by the matrices `A` and `B`. ```jldoctest julia> F = Oscar.Nemo.Native.GF(2); -julia> S, x = polynomial_ring(F, :x) -(Univariate polynomial ring in x over F, x) +julia> S, x = polynomial_ring(F, :x); julia> l = 63; @@ -630,7 +629,7 @@ function bias_tailored_lifted_product_matrices(A::MatElem{T}, B::MatElem{T}) whe A13 = En1 ⊗ B A21 = A ⊗ En2 A24 = Ek1 ⊗ B_tr - return vcat(hcat(zeros(A21), A12, A13, zeros(A24)), hcat(A21, zeros(A12), zeros(A13), A24)) + return vcat(hcat(zero(A21), A12, A13, zero(A24)), hcat(A21, zero(A12), zero(A13), A24)) end """ @@ -644,6 +643,38 @@ Return the pre-lifted stabilizer matrix for bias-tailored lifted product code of # Notes - Use `BiasTailoredLiftedProductCode` to return a quantum code over the base ring directly. + +# Example + +[[882, 24, d ≤ 24]] BiasTailored Lifted Product Code from Appendix B of [roffe2023bias](@cite). + +```jldoctest +julia> F = Oscar.Nemo.Native.GF(2); + +julia> S, x = polynomial_ring(F, :x); + +julia> l = 63; + +julia> R, _ = residue_ring(S, x^l - 1); + +julia> A1 = matrix(R, 1, 1, [1 + x^1 + x^6]); + +julia> A2 = matrix(R, 7, 7, + [x^36, 0 , 0 , 0 , 0 , 1 , x^9, + x^9 , x^36, 0 , 0 , 0 , 0 , 1 , + 1 , x^9 , x^36, 0 , 0 , 0 , 0 , + 0 , 1 , x^9 , x^36, 0 , 0 , 0 , + 0 , 0 , 1 , x^9 , x^36, 0 , 0 , + 0 , 0 , 0 , 1 , x^9 , x^36, 0 , + 0 , 0 , 0 , 0 , 1 , x^9 , x^36]); + +julia> code = BiasTailoredLiftedProductCode(A1, A2); +┌ Warning: Commutativity of A and b required but not yet enforced. +└ @ CodingTheory ~/Desktop/ct/doctests/CodingTheory/src/Quantum/product_codes.jl:60 + +julia> length(code), dimension(code) +(882, 24) +``` """ function bias_tailored_lifted_product_matrices(A::MatElem{T}, B::MatElem{T}) where T <: CTGroupAlgebra @@ -664,7 +695,7 @@ function bias_tailored_lifted_product_matrices(A::MatElem{T}, B::MatElem{T}) whe A13 = En1 ⊗ B A21 = A ⊗ En2 A24 = Ek1 ⊗ B_tr - return vcat(hcat(zeros(A21), A12, A13, zeros(A24)), hcat(A21, zeros(A12), zeros(A13), A24)) + return vcat(hcat(zero(A21), A12, A13, zero(A24)), hcat(A21, zero(A12), zero(A13), A24)) end """ diff --git a/test/Quantum/product_codes_test.jl b/test/Quantum/product_codes_test.jl index c4864a5..b1e13dd 100644 --- a/test/Quantum/product_codes_test.jl +++ b/test/Quantum/product_codes_test.jl @@ -666,4 +666,39 @@ @test dimension(Q) == 12 @test_broken minimum_distance(Q) == 10 end + + @testset "BiasTailoredLiftedProductCode" begin + # [[882, 24, d ≤ 24]] from Appendix B of https://arxiv.org/pdf/2202.01702 + S, x = polynomial_ring(F, :x) + l = 63 + R, _ = residue_ring(S, x^l - 1) + A1 = matrix(R, 1, 1, [1 + x^1 + x^6]) + A2 = matrix(R, 7, 7, + [x^36, 0 , 0 , 0 , 0 , 1 , x^9, + x^9 , x^36, 0 , 0 , 0 , 0 , 1 , + 1 , x^9 , x^36, 0 , 0 , 0 , 0 , + 0 , 1 , x^9 , x^36, 0 , 0 , 0 , + 0 , 0 , 1 , x^9 , x^36, 0 , 0 , + 0 , 0 , 0 , 1 , x^9 , x^36, 0 , + 0 , 0 , 0 , 0 , 1 , x^9 , x^36]) + Q = BiasTailoredLiftedProductCode(A1, A2) + @test length(Q) == 882 + @test dimension(Q) == 24 + @test_broken minimum_distance(Q) == 24 + + # [[416, 18, d ≤ 20]] from Example 4.1 of https://arxiv.org/pdf/2202.01702 + S, x = polynomial_ring(F, :x) + l = 13 + R, _ = residue_ring(S, x^l - 1) + A1 = matrix(R, 4, 4, + [1 , x^11, x^7 , x^12, + x^1 , x^8 , x^2 , x^8 , + x^11, 1 , x^4 , x^8 , + x^6 , x^1 , x^4 , x^12,]) + A2 = A1 + Q = BiasTailoredLiftedProductCode(A1, A2) + @test length(Q) == 416 + @test dimension(Q) == 18 + @test_broken minimum_distance(Q) == 20 + end end From cda23af8e1998dae738165c94d01acc668f7d396 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sat, 12 Oct 2024 14:18:06 +0500 Subject: [PATCH 03/12] fix bug in SPCDFoldProductCode and add its doctest --- docs/src/references.bib | 10 +++++++ src/Quantum/product_codes.jl | 45 +++++++++++++++++++++++++++--- test/Quantum/product_codes_test.jl | 9 +++--- 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/docs/src/references.bib b/docs/src/references.bib index e91e3cc..fdd83ea 100644 --- a/docs/src/references.bib +++ b/docs/src/references.bib @@ -201,3 +201,13 @@ @article{wang2024coprime journal={arXiv preprint arXiv:2408.10001}, year={2024} } + +@article{ostrev2024classical, + title={Classical product code constructions for quantum Calderbank-Shor-Steane codes}, + author={Ostrev, Dimiter and Orsucci, Davide and L{\'a}zaro, Francisco and Matuz, Balazs}, + journal={Quantum}, + volume={8}, + pages={1420}, + year={2024}, + publisher={Verein zur F{\"o}rderung des Open Access Publizierens in den Quantenwissenschaften} +} diff --git a/src/Quantum/product_codes.jl b/src/Quantum/product_codes.jl index 6c76978..6a83ed5 100644 --- a/src/Quantum/product_codes.jl +++ b/src/Quantum/product_codes.jl @@ -15,8 +15,10 @@ Return the hypergraph product code of matrices `A` and `B`. # Example +[[1922, 50, 16]] Hypergraph Product Code from Appendix B, Example C1 of [panteleev2021degenerate](@cite). + ```jldoctest -[1922, 50, 16]] Hypergraph Product Code from Appendix B, Example C1 of [panteleev2021degenerate](@cite). +julia> using CodingTheory, Oscar; julia> F, x = polynomial_ring(Oscar.Nemo.Native.GF(2), :x); @@ -285,6 +287,8 @@ Return the generealized bicycle code given by `A` and `B`. [[254, 28, 14 ≤ d ≤ 20]] Generalized Bicycle Code from Appendix B, Example A1 of [panteleev2021degenerate](@cite). ```jldoctest +julia> using CodingTheory, Oscar; + julia> F = Oscar.Nemo.Native.GF(2); julia> S, x = polynomial_ring(F, :x); @@ -558,6 +562,8 @@ Return the lifted product code given by the matrices `A` and `B`. [[882, 24, 18 ≤ d ≤ 24]] Lifted Product Code from Appendix B, Example B1 of [panteleev2021degenerate](@cite). ```jldoctest +julia> using CodingTheory, Oscar; + julia> F = Oscar.Nemo.Native.GF(2); julia> S, x = polynomial_ring(F, :x); @@ -649,6 +655,8 @@ Return the pre-lifted stabilizer matrix for bias-tailored lifted product code of [[882, 24, d ≤ 24]] BiasTailored Lifted Product Code from Appendix B of [roffe2023bias](@cite). ```jldoctest +julia> using CodingTheory, Oscar; + julia> F = Oscar.Nemo.Native.GF(2); julia> S, x = polynomial_ring(F, :x); @@ -722,6 +730,35 @@ Return the single-parity-check `D`-fold product code. # Note - This is defined in https://arxiv.org/abs/2209.13474 + +# Example + +[512, 174, 8]] Symmetric 2-fold product CSS code from [ostrev2024classical](@cite) + +```jldoctest +julia> using CodingTheory, Oscar; + +julia> F = Oscar.Nemo.Native.GF(2); + +julia> h = matrix(F, [1 1]); + +julia> id = identity_matrix(F, 2); + +julia> H_X = vcat( + h ⊗ h ⊗ h ⊗ id ⊗ id ⊗ id ⊗ id ⊗ id ⊗ id, + id ⊗ id ⊗ id ⊗ h ⊗ h ⊗ h ⊗ id ⊗ id ⊗ id, + id ⊗ id ⊗ id ⊗ id ⊗ id ⊗ id ⊗ h ⊗ h ⊗ h); + +julia> H_Z = vcat( + h ⊗ id ⊗ id ⊗ h ⊗ id ⊗ id ⊗ h ⊗ id ⊗ id, + id ⊗ h ⊗ id ⊗ id ⊗ h ⊗ id ⊗ id ⊗ h ⊗ id, + id ⊗ id ⊗ h ⊗ id ⊗ id ⊗ h ⊗ id ⊗ id ⊗ h); + +julia> code = SPCDFoldProductCode(3); + +julia> length(code), dimension(code) +(512, 174) +``` """ function SPCDFoldProductCode(D::Int, s::Int = 1) vec_S = Vector{AbstractStabilizerCode}() @@ -737,8 +774,8 @@ function SPCDFoldProductCode(D::Int, s::Int = 1) end S = symmetric_product(vec_S) - set_minimum_X_distance!(S, 2^D) - set_minimum_Z_distance!(S, 2^D) + set_X_minimum_distance!(S, 2^D) + set_Z_minimum_distance!(S, 2^D) S.pure = true # metacheck distance = 3 return S @@ -1088,7 +1125,7 @@ Return the coprime bivariate bicycle code defined by the residue ring elements ` # Example -[126, 12, 10]] Coprime Bivariate Bicycle Code from Table 2 of [wang2024coprime](@cite). +[[126, 12, 10]] Coprime Bivariate Bicycle Code from Table 2 of [wang2024coprime](@cite). ```jldoctest julia> using CodingTheory, Oscar; diff --git a/test/Quantum/product_codes_test.jl b/test/Quantum/product_codes_test.jl index b1e13dd..2657464 100644 --- a/test/Quantum/product_codes_test.jl +++ b/test/Quantum/product_codes_test.jl @@ -385,7 +385,7 @@ end @testset "Product Codes" begin - # should list that paper here + # [512, 174, 8]] SPCDFoldProductCode from Section 4 of https://arxiv.org/pdf/2209.13474 F = Oscar.Nemo.Native.GF(2) h = matrix(F, [1 1]) id = identity_matrix(F, 2) @@ -397,11 +397,12 @@ h ⊗ id ⊗ id ⊗ h ⊗ id ⊗ id ⊗ h ⊗ id ⊗ id, id ⊗ h ⊗ id ⊗ id ⊗ h ⊗ id ⊗ id ⊗ h ⊗ id, id ⊗ id ⊗ h ⊗ id ⊗ id ⊗ h ⊗ id ⊗ id ⊗ h) - SPCtest = CodingTheory.SPCDFoldProductCode(3) + SPCtest = SPCDFoldProductCode(3) @test length(SPCtest) == 512 @test dimension(SPCtest) == 174 - @test H_X == SPCtest.X_stabs - @test H_Z == SPCtest.Z_stabs + @test_broken minimum_distance(SPCtest) == 8 + @test_broken H_X == SPCtest.X_stabs + @test_broken H_Z == SPCtest.Z_stabs end @testset "BivariateBicycleCode" begin From 7d7b89ad5965ef0258601c6b3f0cd6d0e7aeab2a Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sat, 12 Oct 2024 14:26:03 +0500 Subject: [PATCH 04/12] comment out warn macro as it appears in doctests --- src/Quantum/product_codes.jl | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Quantum/product_codes.jl b/src/Quantum/product_codes.jl index 6a83ed5..f3e034a 100644 --- a/src/Quantum/product_codes.jl +++ b/src/Quantum/product_codes.jl @@ -385,7 +385,7 @@ Return the pre-lifted matrices `H_X` and `H_Z` of the generalized hypergraph pro """ function generalized_hypergraph_product_matrices(A::MatElem{T}, b::T) where T <: ResElem - @warn "Commutativity of A and b required but not yet enforced." + # @warn "Commutativity of A and b required but not yet enforced." S = base_ring(b) F = base_ring(S) # Int(order(F)) == 2 || throw(ArgumentError("The generalized hypergraph product is only defined over GF(2).")) @@ -496,7 +496,7 @@ Return the pre-lifted matrices `H_X` and `H_Z` for the lifted quasi-cyclic lifte - Use `LiftedProductCode` to return a quantum code over the base ring directly. """ function lifted_product_matrices(A::MatElem{T}, B::MatElem{T}) where T <: ResElem - @warn "Commutativity of A and b required but not yet enforced." + # @warn "Commutativity of A and b required but not yet enforced." S = base_ring(A[1, 1]) F = base_ring(S) Int(order(F)) == 2 || throw(ArgumentError("The quasi-cyclic lifted product is only defined over GF(2).")) @@ -584,8 +584,6 @@ julia> A = matrix(R, 7, 7, julia> b = R(1 + x + x^6); julia> code = LiftedProductCode(A, b); -┌ Warning: Commutativity of A and b required but not yet enforced. -└ @ CodingTheory ~/Desktop/ct/doctests/CodingTheory/src/Quantum/product_codes.jl:340 julia> length(code), dimension(code) (882, 24) @@ -611,7 +609,7 @@ Return the pre-lifted stabilizer matrix for bias-tailored lifted product code of - Use `BiasTailoredLiftedProductCode` to return a quantum code over the base ring directly. """ function bias_tailored_lifted_product_matrices(A::MatElem{T}, B::MatElem{T}) where T <: ResElem - @warn "Commutativity of A and b required but not yet enforced." + # @warn "Commutativity of A and b required but not yet enforced." S = base_ring(A[1, 1]) F = base_ring(S) Int(order(F)) == 2 || throw(ArgumentError("The quasi-cyclic lifted product is only defined over GF(2).")) @@ -677,8 +675,6 @@ julia> A2 = matrix(R, 7, 7, 0 , 0 , 0 , 0 , 1 , x^9 , x^36]); julia> code = BiasTailoredLiftedProductCode(A1, A2); -┌ Warning: Commutativity of A and b required but not yet enforced. -└ @ CodingTheory ~/Desktop/ct/doctests/CodingTheory/src/Quantum/product_codes.jl:60 julia> length(code), dimension(code) (882, 24) From a6607d3f78b2d6648f5d427cf76ad24108b70178 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sat, 12 Oct 2024 15:29:06 +0500 Subject: [PATCH 05/12] add doctests for gaugeShorcode --- docs/src/references.bib | 11 ++++++++ src/Quantum/misc_known_codes.jl | 40 ++++++++++++++++++++++++++++++ src/Quantum/product_codes.jl | 2 +- test/Quantum/product_codes_test.jl | 3 ++- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/docs/src/references.bib b/docs/src/references.bib index fdd83ea..fbe6b68 100644 --- a/docs/src/references.bib +++ b/docs/src/references.bib @@ -109,6 +109,17 @@ @misc{Vasmer_2020 year={2020} } +@article{poulin2005stabilizer, + title={Stabilizer formalism for operator quantum error correction}, + author={Poulin, David}, + journal={Physical review letters}, + volume={95}, + number={23}, + pages={230504}, + year={2005}, + publisher={APS} +} + % Product Codes @article{bacon2006quantum, diff --git a/src/Quantum/misc_known_codes.jl b/src/Quantum/misc_known_codes.jl index 5983813..aea3c38 100644 --- a/src/Quantum/misc_known_codes.jl +++ b/src/Quantum/misc_known_codes.jl @@ -8,6 +8,46 @@ # Subsystem codes ############################# +""" +[[9, 1, 4, 3]] gauged Shor code from [poulin2005stabilizer](@cite) + +```jldoctest +julia> using CodingTheory, Oscar; + +julia> code = GaugedShorCode(); + +julia> length(code), dimension(code), code.r +(9, 1, 4) + +julia> code.stabs_stand +[1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0] +[0 1 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0] +[0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0] +[0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1 1] + +julia> code.logicals +1-element Vector{Tuple{fpMatrix, fpMatrix}}: + ([0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1], [1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0]) + +julia> code.X_stabs +[1 1 1 1 1 1 0 0 0] +[1 1 1 0 0 0 1 1 1] + +julia> code.Z_stabs +[1 1 0 1 1 0 1 1 0] +[0 1 1 0 1 1 0 1 1] + +julia> code.g_ops_mat +[0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0] +[0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0] +[0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0] +[0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0] +[0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0] +[1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0] +[0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0] +[0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0] +``` +""" function GaugedShorCode() # Poulin, "Stabilizer Formalism for Operator Quantum Error Correction", (2008) # [[9, 1, 4, 3]] gauged Shor code diff --git a/src/Quantum/product_codes.jl b/src/Quantum/product_codes.jl index f3e034a..aa3a985 100644 --- a/src/Quantum/product_codes.jl +++ b/src/Quantum/product_codes.jl @@ -666,7 +666,7 @@ julia> R, _ = residue_ring(S, x^l - 1); julia> A1 = matrix(R, 1, 1, [1 + x^1 + x^6]); julia> A2 = matrix(R, 7, 7, - [x^36, 0 , 0 , 0 , 0 , 1 , x^9, + [x^36, 0 , 0 , 0 , 0 , 1 , x^9 , x^9 , x^36, 0 , 0 , 0 , 0 , 1 , 1 , x^9 , x^36, 0 , 0 , 0 , 0 , 0 , 1 , x^9 , x^36, 0 , 0 , 0 , diff --git a/test/Quantum/product_codes_test.jl b/test/Quantum/product_codes_test.jl index 2657464..b6f8cef 100644 --- a/test/Quantum/product_codes_test.jl +++ b/test/Quantum/product_codes_test.jl @@ -670,12 +670,13 @@ @testset "BiasTailoredLiftedProductCode" begin # [[882, 24, d ≤ 24]] from Appendix B of https://arxiv.org/pdf/2202.01702 + F = Oscar.Nemo.Native.GF(2) S, x = polynomial_ring(F, :x) l = 63 R, _ = residue_ring(S, x^l - 1) A1 = matrix(R, 1, 1, [1 + x^1 + x^6]) A2 = matrix(R, 7, 7, - [x^36, 0 , 0 , 0 , 0 , 1 , x^9, + [x^36, 0 , 0 , 0 , 0 , 1 , x^9 , x^9 , x^36, 0 , 0 , 0 , 0 , 1 , 1 , x^9 , x^36, 0 , 0 , 0 , 0 , 0 , 1 , x^9 , x^36, 0 , 0 , 0 , From 307aa10388d27bf650af6d87c5bed1d5abb46d24 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sat, 12 Oct 2024 20:09:01 +0500 Subject: [PATCH 06/12] doctests for CSS and non-CSS HyperBicycleCode --- src/Quantum/product_codes.jl | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/Quantum/product_codes.jl b/src/Quantum/product_codes.jl index aa3a985..f209e31 100644 --- a/src/Quantum/product_codes.jl +++ b/src/Quantum/product_codes.jl @@ -176,6 +176,31 @@ Return the hyperbicycle CSS code of `a` and `b` given `χ`. - b: A vector of length `c` of binary matrices of the same dimensions, potentially different from those of `a`. - χ: A strictly positive integer coprime with `c`. + +# Example + +[[900, 50, 14]] CSS Hyperbicycle Code from Example 6 of [Kovalev_2013](@cite). + +```jldoctest +julia> S, x = polynomial_ring(Oscar.Nemo.Native.GF(2), :x); + +julia> l = 30; χ = 1; + +julia> R, = residue_ring(S, x^l - 1); + +julia> h = R(1 + x + x^3 + x^5); + +julia> A = residue_polynomial_to_circulant_matrix(h); + +julia> a1 = A[1:15, 1:15]; + +julia> a2 = A[1:15, 16:30]; + +julia> code = HyperBicycleCodeCSS([a1, a2], [a1, a2], χ); + +julia> length(code), dimension(code) +(900, 50) +``` """ function HyperBicycleCodeCSS(a::Vector{T}, b::Vector{T}, χ::Int; char_vec::Union{Vector{zzModRingElem}, Missing} = missing, logs_alg::Symbol = :stnd_frm) where T <: CTMatrixTypes @@ -232,6 +257,29 @@ Return the hyperbicycle non-CSS code of `a` and `b` given `χ`. - b: A vector of length `c` of binary matrices of the same dimensions, potentially different from those of `a`. - χ: A strictly positive integer coprime with `c`. + +# Example + +[[289, 81, 5]] non-CSS Hyperbicycle Code from Example 13 of [Kovalev_2013](@cite). + +```jldoctest +julia> using CodingTheory, Oscar; + +julia> S, x = polynomial_ring(Oscar.Nemo.Native.GF(2), :x); + +julia> l = 17; χ = 1; + +julia> R, = residue_ring(S, x^l - 1); + +julia> h = R(x^4 * (1 + x + x^3 + x^6 + x^8 + x^9)); + +julia> A = residue_polynomial_to_circulant_matrix(h); + +julia> code = HyperBicycleCode([A], [A], χ); + +julia> length(code), dimension(code) +(289, 81) +``` """ function HyperBicycleCode(a::Vector{T}, b::Vector{T}, χ::Int, char_vec::Union{Vector{zzModRingElem}, Missing} = missing, logs_alg::Symbol = :stnd_frm) where T <: CTMatrixTypes From 73e45d8d1504321cd9ba8e4a69c88176b7be0bd0 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sat, 12 Oct 2024 20:52:51 +0500 Subject: [PATCH 07/12] fix warning of MakieExt weight_plot --- docs/Project.toml | 3 ++- ext/MakieExt/Classical/Tanner.jl | 2 +- ext/MakieExt/Classical/weight_dist.jl | 2 +- ext/MakieExt/LDPC/analysis.jl | 2 +- ext/MakieExt/LDPC/codes.jl | 10 +++++----- ext/MakieExt/Quantum/weight_dist.jl | 8 ++++---- src/Quantum/misc_known_codes.jl | 1 + 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index 2a69570..135de1a 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,12 +1,13 @@ [deps] -BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232" BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232" CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" CodingTheory = "7ca085cf-10e4-43da-ad7d-8f62f68877b3" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244" Hecke = "3e1990a7-5d81-5526-99ce-9ba3ff248f21" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/ext/MakieExt/Classical/Tanner.jl b/ext/MakieExt/Classical/Tanner.jl index 445825c..89a9cd4 100644 --- a/ext/MakieExt/Classical/Tanner.jl +++ b/ext/MakieExt/Classical/Tanner.jl @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. """ - Tanner_graph_plot(H::Union{CTMatrixTypes, Matrix{Int}}) +$TYPEDSIGNATURES Return the Tanner graph of the matrix `H` as a `Figure` object. diff --git a/ext/MakieExt/Classical/weight_dist.jl b/ext/MakieExt/Classical/weight_dist.jl index 9028b08..b195f92 100644 --- a/ext/MakieExt/Classical/weight_dist.jl +++ b/ext/MakieExt/Classical/weight_dist.jl @@ -9,7 +9,7 @@ ############################# """ - weight_plot(C::AbstractLinearCode; alg::Symbol = :auto) +$TYPEDSIGNATURES Return a bar graph of the weight distribution of `C`. diff --git a/ext/MakieExt/LDPC/analysis.jl b/ext/MakieExt/LDPC/analysis.jl index 95c620a..b4c54ce 100644 --- a/ext/MakieExt/LDPC/analysis.jl +++ b/ext/MakieExt/LDPC/analysis.jl @@ -9,7 +9,7 @@ ############################# """ - EXIT_chart_plot(E::LDPCEnsemble, Ch::AbstractClassicalNoiseChannel; tol::Float64 = 1e-9) +$TYPEDSIGNATURES Return a plot of the EXIT chart for the ensemble given the channel up to a numerical tolerance of `tol`. diff --git a/ext/MakieExt/LDPC/codes.jl b/ext/MakieExt/LDPC/codes.jl index b67942f..964676d 100644 --- a/ext/MakieExt/LDPC/codes.jl +++ b/ext/MakieExt/LDPC/codes.jl @@ -9,7 +9,7 @@ ############################# """ - degree_distributions_plot(C::AbstractLDPCCode) +$TYPEDSIGNATURES Return a bar plot of the column and row degree distributions of `C`. @@ -44,7 +44,7 @@ function CodingTheory.degree_distributions_plot(C::AbstractLDPCCode) end """ - count_short_cycles_plot(C::AbstractLDPCCode) +$TYPEDSIGNATURES Return a bar graph and a dictionary of (length, count) pairs for unique short cycles in the Tanner graph of `C`. An empty graph and dictionary are returned @@ -82,7 +82,7 @@ function CodingTheory.count_short_cycles_plot(C::AbstractLDPCCode) end """ - count_elementary_cycles_plot(C::AbstractLDPCCode) +$TYPEDSIGNATURES Return a bar graph and a dictionary of (length, count) pairs for unique elementary cycles in the Tanner graph of `C`. An empty graph and dictionary are returned @@ -120,7 +120,7 @@ function CodingTheory.count_elementary_cycles_plot(C::AbstractLDPCCode) end """ - ACE_spectrum(C::AbstractLDPCCode) +$TYPEDSIGNATURES Return an interactive figure and data for the ACE spectrum of the Tanner graph of `C`. @@ -171,7 +171,7 @@ end # doesn't seem to be a point in making this dynamic with a slider, as it simply # continues in the same tree shape and no useful information is gained from watching it """ - computation_graph(C::AbstractLDPCCode, lvl::Int, v::Int, v_type::Symbol=:v) +$TYPEDSIGNATURES Return a figure representing the expansion of the Tanner graph of `C` to level `lvl` for node `v`. If `v_type` is `:v`, `v` is interpreted as a variable node; otherwise, diff --git a/ext/MakieExt/Quantum/weight_dist.jl b/ext/MakieExt/Quantum/weight_dist.jl index ca1d34d..ed552d6 100644 --- a/ext/MakieExt/Quantum/weight_dist.jl +++ b/ext/MakieExt/Quantum/weight_dist.jl @@ -9,7 +9,7 @@ ############################# """ - weight_plot(S::AbstractStabilizerCode; alg::Symbol = :auto, type::Symbol = :stabilizer) +$TYPEDSIGNATURES Return a bar graph of the weight distribution related to `S`. @@ -49,7 +49,7 @@ function CodingTheory.weight_plot(S::AbstractStabilizerCode; alg::Symbol = :auto end """ - weight_plot_CSS_X(S::AbstractStabilizerCodeCSS; alg::Symbol = :auto) +$TYPEDSIGNATURES Return a bar graph of the weight distribution of the `X` stabilizers. @@ -73,7 +73,7 @@ function CodingTheory.weight_plot_CSS_X(S::AbstractStabilizerCodeCSS; alg::Symbo end """ - weight_plot_CSS_Z(S::AbstractStabilizerCodeCSS; alg::Symbol = :auto) +$TYPEDSIGNATURES Return a bar graph of the weight distribution of the `Z` stabilizers. @@ -97,7 +97,7 @@ function CodingTheory.weight_plot_CSS_Z(S::AbstractStabilizerCodeCSS; alg::Symbo end """ - weight_plot_CSS(S::AbstractStabilizerCodeCSS; alg::Symbol = :auto) +$TYPEDSIGNATURES Return bar graphs of the weight distribution of both the `X` and 'Z' stabilizers, separately. diff --git a/src/Quantum/misc_known_codes.jl b/src/Quantum/misc_known_codes.jl index aea3c38..fce2dea 100644 --- a/src/Quantum/misc_known_codes.jl +++ b/src/Quantum/misc_known_codes.jl @@ -181,6 +181,7 @@ function BravyiBaconShorCode(A::CTMatrixTypes) # but this is corrected here to match # X - consequetive column pairs X_gauges = zero_matrix(F, sum([col_wts[i] - 1 for i in 1:length(col_wts)]), n) + typeof(X_gauges) curr_row = 1 F_one = F(1) for c in 1:nc From 1b986be3b5e13d18d992a6cc09f7ba4fb8c222c1 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sun, 13 Oct 2024 07:27:05 +0500 Subject: [PATCH 08/12] add code review suggestions --- src/Quantum/misc_known_codes.jl | 41 ------------------------------ src/Quantum/product_codes.jl | 2 +- test/Quantum/product_codes_test.jl | 4 +-- 3 files changed, 3 insertions(+), 44 deletions(-) diff --git a/src/Quantum/misc_known_codes.jl b/src/Quantum/misc_known_codes.jl index fe53971..b441587 100644 --- a/src/Quantum/misc_known_codes.jl +++ b/src/Quantum/misc_known_codes.jl @@ -8,46 +8,6 @@ # Subsystem codes ############################# -""" -[[9, 1, 4, 3]] gauged Shor code from [poulin2005stabilizer](@cite) - -```jldoctest -julia> using CodingTheory, Oscar; - -julia> code = GaugedShorCode(); - -julia> length(code), dimension(code), code.r -(9, 1, 4) - -julia> code.stabs_stand -[1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0] -[0 1 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0] -[0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0] -[0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1 1] - -julia> code.logicals -1-element Vector{Tuple{fpMatrix, fpMatrix}}: - ([0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1], [1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0]) - -julia> code.X_stabs -[1 1 1 1 1 1 0 0 0] -[1 1 1 0 0 0 1 1 1] - -julia> code.Z_stabs -[1 1 0 1 1 0 1 1 0] -[0 1 1 0 1 1 0 1 1] - -julia> code.g_ops_mat -[0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0] -[0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0] -[0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0] -[0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0] -[0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0] -[1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0] -[0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0] -[0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0] -``` -""" function GaugedShorCode() # Poulin, "Stabilizer Formalism for Operator Quantum Error Correction", (2008) # [[9, 1, 4, 3]] gauged Shor code @@ -183,7 +143,6 @@ function BravyiBaconShorCode(A::CTMatrixTypes) # but this is corrected here to match # X - consequetive column pairs X_gauges = zero_matrix(F, sum([col_wts[i] - 1 for i in 1:length(col_wts)]), n) - typeof(X_gauges) curr_row = 1 F_one = F(1) for c in 1:nc diff --git a/src/Quantum/product_codes.jl b/src/Quantum/product_codes.jl index 94ad51c..bf4df41 100644 --- a/src/Quantum/product_codes.jl +++ b/src/Quantum/product_codes.jl @@ -1166,7 +1166,7 @@ Return the coprime bivariate bicycle code defined by the residue ring elements ` # Note -- This is defined in https://arxiv.org/pdf/2408.10001v1. +- This is defined in https://arxiv.org/pdf/2408.10001. """ function CoprimeBivariateBicycleCode(a::ResElem, b::ResElem) R = parent(a) diff --git a/test/Quantum/product_codes_test.jl b/test/Quantum/product_codes_test.jl index 670e0e8..efa4994 100644 --- a/test/Quantum/product_codes_test.jl +++ b/test/Quantum/product_codes_test.jl @@ -399,8 +399,8 @@ @test length(SPCtest) == 512 @test dimension(SPCtest) == 174 @test_broken minimum_distance(SPCtest) == 8 - @test_broken H_X == SPCtest.X_stabs - @test_broken H_Z == SPCtest.Z_stabs + @test H_X == SPCtest.X_stabs + @test H_Z == SPCtest.Z_stabs end @testset "BivariateBicycleCode" begin From 43cbac3979512e9df95085a2ce86c6d3eec8476b Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sun, 13 Oct 2024 07:35:29 +0500 Subject: [PATCH 09/12] fix documentation site name --- docs/make.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/make.jl b/docs/make.jl index 3c9dc88..ede7741 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -9,7 +9,7 @@ Documenter.makedocs(; modules = Module[CodingTheory], repo = "", highlightsig = true, - sitename = "Coding Theory Documentation", + sitename = "CodingTheory.jl", expandfirst = [], warnonly = [:missing_docs], pages = ["Introduction" => "index.md", From f8f940c4cbdca110df71c021572e53b5c2babc24 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sun, 13 Oct 2024 07:55:22 +0500 Subject: [PATCH 10/12] fix bug in weight reduction LP tutorial --- docs/src/Tutorials/Weight Reduction.md | 43 +++++++++----------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/docs/src/Tutorials/Weight Reduction.md b/docs/src/Tutorials/Weight Reduction.md index 997b1a8..795a8a8 100644 --- a/docs/src/Tutorials/Weight Reduction.md +++ b/docs/src/Tutorials/Weight Reduction.md @@ -678,42 +678,27 @@ Dict(78 => 28, 56 => 2894, 16 => 13428, 20 => 24654, 58 => 15616, 52 => 7728, 60 ## Lifted Products Classical weight reduction also applies to other types of inputs, although with the current function, the row and column indices must be specified explicitly either as a vector or a range. ``` -julia> F = GF(2); - -julia> S, x = PolynomialRing(F, "x"); +julia> S, x = polynomial_ring(Oscar.Nemo.Native.GF(2), "x"); julia> l = 63; -julia> R = ResidueRing(S, x^l - 1); +julia> R, = residue_ring(S, x^l - 1); julia> A = matrix(R, 7, 7, - [x^27, 0, 0, 1, x^18, x^27, 1, - 1, x^27, 0, 0, 1, x^18, x^27, - x^27, 1, x^27, 0, 0, 1, x^18, - x^18, x^27, 1, x^27, 0, 0, 1, - 1, x^18, x^27, 1, x^27, 0, 0, - 0, 1, x^18, x^27, 1, x^27, 0, - 0, 0, 1, x^18, x^27, 1, x^27]) -[x^27 0 0 1 x^18 x^27 1] -[ 1 x^27 0 0 1 x^18 x^27] -[x^27 1 x^27 0 0 1 x^18] -[x^18 x^27 1 x^27 0 0 1] -[ 1 x^18 x^27 1 x^27 0 0] -[ 0 1 x^18 x^27 1 x^27 0] -[ 0 0 1 x^18 x^27 1 x^27] - -julia> b = R(1 + x + x^6) -x^6 + x + 1 - -julia> LiftedProductCode(A, b) -┌ Warning: Commutativity of A and b required but not yet enforced. -└ @ CodingTheory ~/Documents/GitHub/CodingTheory/src/Quantum/product_codes.jl:354 -[[882, 48]]_2 CSS stabilizer code + [x^27, 0 , 0 , 1 , x^18, x^27, 1 , + 1 , x^27, 0 , 0 , 1 , x^18, x^27, + x^27, 1 , x^27, 0 , 0 , 1 , x^18, + x^18, x^27, 1 , x^27, 0 , 0 , 1 , + 1 , x^18, x^27, 1 , x^27, 0 , 0 , + 0 , 1 , x^18, x^27, 1 , x^27, 0 , + 0 , 0 , 1 , x^18, x^27, 1 , x^27]); -julia> A_wtred = weight_reduction(A, row_indices = 1:4, column_indices = 1:4, permute_rows = false, permute_columns = false); +julia> b = R(1 + x + x^6); -julia> LiftedProductCode(A_wtred, b) +julia> code = LiftedProductCode(A, b); ┌ Warning: Commutativity of A and b required but not yet enforced. └ @ CodingTheory ~/Documents/GitHub/CodingTheory/src/Quantum/product_codes.jl:354 -[[4914, 48]]_2 CSS stabilizer code + +julia> length(code), dimension(code) +(882, 48) ``` From f786b0dff9ce517af9a0644c03641fcd134f68b1 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sun, 13 Oct 2024 08:01:47 +0500 Subject: [PATCH 11/12] uncomment warn macro --- docs/src/Tutorials/Weight Reduction.md | 2 +- src/Quantum/product_codes.jl | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/src/Tutorials/Weight Reduction.md b/docs/src/Tutorials/Weight Reduction.md index 795a8a8..4692787 100644 --- a/docs/src/Tutorials/Weight Reduction.md +++ b/docs/src/Tutorials/Weight Reduction.md @@ -697,7 +697,7 @@ julia> b = R(1 + x + x^6); julia> code = LiftedProductCode(A, b); ┌ Warning: Commutativity of A and b required but not yet enforced. -└ @ CodingTheory ~/Documents/GitHub/CodingTheory/src/Quantum/product_codes.jl:354 +└ @ CodingTheory ~/Documents/GitHub/CodingTheory/src/Quantum/product_codes.jl:340 julia> length(code), dimension(code) (882, 48) diff --git a/src/Quantum/product_codes.jl b/src/Quantum/product_codes.jl index bf4df41..dd214f3 100644 --- a/src/Quantum/product_codes.jl +++ b/src/Quantum/product_codes.jl @@ -433,7 +433,7 @@ Return the pre-lifted matrices `H_X` and `H_Z` of the generalized hypergraph pro """ function generalized_hypergraph_product_matrices(A::MatElem{T}, b::T) where T <: ResElem - # @warn "Commutativity of A and b required but not yet enforced." + @warn "Commutativity of A and b required but not yet enforced." S = base_ring(b) F = base_ring(S) # Int(order(F)) == 2 || throw(ArgumentError("The generalized hypergraph product is only defined over GF(2).")) @@ -544,7 +544,7 @@ Return the pre-lifted matrices `H_X` and `H_Z` for the lifted quasi-cyclic lifte - Use `LiftedProductCode` to return a quantum code over the base ring directly. """ function lifted_product_matrices(A::MatElem{T}, B::MatElem{T}) where T <: ResElem - # @warn "Commutativity of A and b required but not yet enforced." + @warn "Commutativity of A and b required but not yet enforced." S = base_ring(A[1, 1]) F = base_ring(S) Int(order(F)) == 2 || throw(ArgumentError("The quasi-cyclic lifted product is only defined over GF(2).")) @@ -632,6 +632,8 @@ julia> A = matrix(R, 7, 7, julia> b = R(1 + x + x^6); julia> code = LiftedProductCode(A, b); +┌ Warning: Commutativity of A and b required but not yet enforced. +└ @ CodingTheory ~/Documents/GitHub/CodingTheory/src/Quantum/product_codes.jl:340 julia> length(code), dimension(code) (882, 24) @@ -657,7 +659,7 @@ Return the pre-lifted stabilizer matrix for bias-tailored lifted product code of - Use `BiasTailoredLiftedProductCode` to return a quantum code over the base ring directly. """ function bias_tailored_lifted_product_matrices(A::MatElem{T}, B::MatElem{T}) where T <: ResElem - # @warn "Commutativity of A and b required but not yet enforced." + @warn "Commutativity of A and b required but not yet enforced." S = base_ring(A[1, 1]) F = base_ring(S) Int(order(F)) == 2 || throw(ArgumentError("The quasi-cyclic lifted product is only defined over GF(2).")) @@ -723,6 +725,8 @@ julia> A2 = matrix(R, 7, 7, 0 , 0 , 0 , 0 , 1 , x^9 , x^36]); julia> code = BiasTailoredLiftedProductCode(A1, A2); +┌ Warning: Commutativity of A and b required but not yet enforced. +└ @ CodingTheory ~/Documents/GitHub/CodingTheory/src/Quantum/product_codes.jl:60 julia> length(code), dimension(code) (882, 24) From f9a7d6c9d3a72faf129d91966ef2ca175ba89bb2 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Thu, 17 Oct 2024 00:56:02 +0500 Subject: [PATCH 12/12] fix the appendix reference - C2 instead of C1 for HGP code --- src/Quantum/product_codes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Quantum/product_codes.jl b/src/Quantum/product_codes.jl index dd214f3..bda0bd0 100644 --- a/src/Quantum/product_codes.jl +++ b/src/Quantum/product_codes.jl @@ -15,7 +15,7 @@ Return the hypergraph product code of matrices `A` and `B`. # Example -[[1922, 50, 16]] Hypergraph Product Code from Appendix B, Example C1 of [panteleev2021degenerate](@cite). +[[1922, 50, 16]] Hypergraph Product Code from Appendix B, Example C2 of [panteleev2021degenerate](@cite). ```jldoctest julia> using CodingTheory, Oscar;