Skip to content

Commit 5eaba44

Browse files
committed
fix doc build, misc bugs and add doctests
1 parent c52fe61 commit 5eaba44

File tree

3 files changed

+138
-3
lines changed

3 files changed

+138
-3
lines changed

docs/Project.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
[deps]
22
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
3+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
4+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
5+
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
36
CodingTheory = "7ca085cf-10e4-43da-ad7d-8f62f68877b3"
7+
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
8+
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
49
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
510
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
11+
Hecke = "3e1990a7-5d81-5526-99ce-9ba3ff248f21"
12+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
13+
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
14+
Oscar = "f1435218-dba5-11e9-1e4d-f1a5fab5fc13"
15+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

src/Quantum/product_codes.jl

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@
1212
HypergraphProductCode(A::CTMatrixTypes, B::CTMatrixTypes; char_vec::Union{Vector{zzModRingElem}, Missing}= missing, logs_alg::Symbol = :stnd_frm)
1313
1414
Return the hypergraph product code of matrices `A` and `B`.
15+
16+
# Example
17+
18+
```jldoctest
19+
[1922, 50, 16]] Hypergraph Product Code from Appendix B, Example C1 of [panteleev2021degenerate](@cite).
20+
21+
julia> F, x = polynomial_ring(Oscar.Nemo.Native.GF(2), :x);
22+
23+
julia> l = 31;
24+
25+
julia> R, = residue_ring(F, x^l -1);
26+
27+
julia> h = R(1 + x^2 + x^5);
28+
29+
julia> A = residue_polynomial_to_circulant_matrix(h);
30+
31+
julia> code = HypergraphProductCode(A, A);
32+
33+
julia> length(code), dimension(code)
34+
(1922, 50)
35+
```
1536
"""
1637
function HypergraphProductCode(A::CTMatrixTypes, B::CTMatrixTypes; char_vec::Union{Vector{zzModRingElem},
1738
Missing} = missing, logs_alg::Symbol = :stnd_frm)
@@ -258,6 +279,29 @@ end
258279
GeneralizedBicycleCode(A::CTMatrixTypes, B::CTMatrixTypes; char_vec::Union{Vector{zzModRingElem}, Missing} = missing, logs_alg::Symbol = :stnd_frm)
259280
260281
Return the generealized bicycle code given by `A` and `B`.
282+
283+
# Example
284+
285+
[[254, 28, 14 ≤ d ≤ 20]] Generalized Bicycle Code from Appendix B, Example A1 of [panteleev2021degenerate](@cite).
286+
287+
```jldoctest
288+
julia> F = Oscar.Nemo.Native.GF(2);
289+
290+
julia> S, x = polynomial_ring(F, :x);
291+
292+
julia> l = 127;
293+
294+
julia> R, _ = residue_ring(S, x^l - 1);
295+
296+
julia> a = 1 + x^15 + x^20 + x^28 + x^66;
297+
298+
julia> b = 1 + x^58 + x^59 + x^100 + x^121;
299+
300+
julia> code = GeneralizedBicycleCode(R(a), R(b));
301+
302+
julia> length(code), dimension(code)
303+
(254, 28)
304+
```
261305
"""
262306
function GeneralizedBicycleCode(A::T, B::T; char_vec::Union{Vector{zzModRingElem}, Missing} = missing,
263307
logs_alg::Symbol = :stnd_frm) where T <: CTMatrixTypes
@@ -508,6 +552,39 @@ end
508552
LiftedProductCode(A::MatElem{T}, B::MatElem{T}; char_vec::Union{Vector{zzModRingElem}, Missing} = missing, logs_alg::Symbol = :stnd_frm) where T <: Union{ResElem, CTGroupAlgebra}
509553
510554
Return the lifted product code given by the matrices `A` and `B`.
555+
556+
# Example
557+
558+
[[882, 24, 18 ≤ d ≤ 24]] Lifted Product Code from Appendix B, Example B1 of [panteleev2021degenerate](@cite).
559+
560+
```jldoctest
561+
julia> F = Oscar.Nemo.Native.GF(2);
562+
563+
julia> S, x = polynomial_ring(F, :x)
564+
(Univariate polynomial ring in x over F, x)
565+
566+
julia> l = 63;
567+
568+
julia> R, _ = residue_ring(S, x^l - 1);
569+
570+
julia> A = matrix(R, 7, 7,
571+
[x^27, 0 , 0 , 0 , 0 , 1 , x^54,
572+
x^54, x^27, 0 , 0 , 0 , 0 , 1 ,
573+
1 , x^54, x^27, 0 , 0 , 0 , 0 ,
574+
0 , 1 , x^54, x^27, 0 , 0 , 0 ,
575+
0 , 0 , 1 , x^54, x^27, 0 , 0 ,
576+
0 , 0 , 0 , 1 , x^54, x^27, 0 ,
577+
0 , 0 , 0 , 0 , 1 , x^54, x^27]);
578+
579+
julia> b = R(1 + x + x^6);
580+
581+
julia> code = LiftedProductCode(A, b);
582+
┌ Warning: Commutativity of A and b required but not yet enforced.
583+
└ @ CodingTheory ~/Desktop/ct/doctests/CodingTheory/src/Quantum/product_codes.jl:340
584+
585+
julia> length(code), dimension(code)
586+
(882, 24)
587+
```
511588
"""
512589
function LiftedProductCode(A::MatElem{T}, B::MatElem{T}; char_vec::Union{Vector{zzModRingElem}, Missing} =
513590
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 `
894971
895972
# Note
896973
- This is defined in https://arxiv.org/pdf/2308.07915
974+
975+
# Example
976+
977+
[[360, 12, ≤24]] Bivariate Bicycle Code from Table 3 of [bravyi2024high](@cite).
978+
979+
```jldoctest
980+
julia> using CodingTheory, Oscar;
981+
982+
julia> S, (x, y) = polynomial_ring(Oscar.Nemo.Native.GF(2), [:x, :y]);
983+
984+
julia> l = 30; m = 6;
985+
986+
julia> R, _ = quo(S, ideal(S, [x^l - 1, y^m - 1]));
987+
988+
julia> a = R(x^9 + y + y^2);
989+
990+
julia> b = R(y^3 + x^25 + x^26);
991+
992+
julia> code = BivariateBicycleCode(a, b);
993+
994+
julia> length(code), dimension(code)
995+
(360, 12)
996+
```
897997
"""
898998
function BivariateBicycleCode(a::T, b::T) where T <: Union{MPolyQuoRingElem{FqMPolyRingElem}, MPolyQuoRingElem{fpMPolyRingElem}}
899999
R = parent(a)
@@ -954,6 +1054,29 @@ Return the coprime bivariate bicycle code defined by the residue ring elements `
9541054
9551055
# Note
9561056
- This is defined in https://arxiv.org/pdf/2408.10001v1.
1057+
1058+
# Example
1059+
1060+
[126, 12, 10]] Coprime Bivariate Bicycle Code from Table 2 of [wang2024coprime](@cite).
1061+
1062+
```jldoctest
1063+
julia> using CodingTheory, Oscar;
1064+
1065+
julia> S, (P) = polynomial_ring(Oscar.Nemo.Native.GF(2), [:P]);
1066+
1067+
julia> l = 7; m = 9;
1068+
1069+
julia> R, _ = quo(S, ideal(S, [P[1]^(l*m)]));
1070+
1071+
julia> a = R(1 + P[1] + P[1]^58);
1072+
1073+
julia> b = R(P[1]^3 + P[1]^16 + P[1]^44);
1074+
1075+
julia> code = CoprimeBivariateBicycleCode(a, b);
1076+
1077+
julia> length(code), dimension(code)
1078+
(126, 12)
1079+
```
9571080
"""
9581081
function CoprimeBivariateBicycleCode(a::T, b::T) where T <: Union{MPolyQuoRingElem{FqMPolyRingElem}, MPolyQuoRingElem{fpMPolyRingElem}}
9591082
R = parent(a)

test/Quantum/product_codes_test.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,9 @@
198198
# takes awhile to run
199199

200200
# Example C2
201-
F = Oscar.Nemo.Native.GF(2)
202-
S, x = polynomial_ring(F, :x)
201+
F, x = polynomial_ring(Oscar.Nemo.Native.GF(2), :x)
203202
l = 31
204-
R = ResidueRing(S, x^l - 1)
203+
R, = residue_ring(F, x^l -1)
205204
h = R(1 + x^2 + x^5)
206205
A = residue_polynomial_to_circulant_matrix(h)
207206
Q = HypergraphProductCode(A, A)
@@ -606,7 +605,9 @@
606605
@test length(Q) == 196
607606
@test dimension(Q) == 12
608607
@test_broken minimum_distance(S) == 8
608+
end
609609

610+
@testset "CoprimeBivariateBicycleCode" begin
610611
# Coprime Bivariate Bicycle codes
611612
# Table 2 of https://arxiv.org/pdf/2408.10001v1
612613
# [[30, 4, 6]]
@@ -664,4 +665,5 @@
664665
@test length(Q) == 126
665666
@test dimension(Q) == 12
666667
@test_broken minimum_distance(Q) == 10
668+
end
667669
end

0 commit comments

Comments
 (0)