Skip to content

Commit 23a916b

Browse files
committed
fix bug in BiasTailoredLiftedProductCode and add its tests, doctests
1 parent 5eaba44 commit 23a916b

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed

src/Quantum/product_codes.jl

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,7 @@ Return the lifted product code given by the matrices `A` and `B`.
560560
```jldoctest
561561
julia> F = Oscar.Nemo.Native.GF(2);
562562
563-
julia> S, x = polynomial_ring(F, :x)
564-
(Univariate polynomial ring in x over F, x)
563+
julia> S, x = polynomial_ring(F, :x);
565564
566565
julia> l = 63;
567566
@@ -630,7 +629,7 @@ function bias_tailored_lifted_product_matrices(A::MatElem{T}, B::MatElem{T}) whe
630629
A13 = En1 B
631630
A21 = A En2
632631
A24 = Ek1 B_tr
633-
return vcat(hcat(zeros(A21), A12, A13, zeros(A24)), hcat(A21, zeros(A12), zeros(A13), A24))
632+
return vcat(hcat(zero(A21), A12, A13, zero(A24)), hcat(A21, zero(A12), zero(A13), A24))
634633
end
635634

636635
"""
@@ -644,6 +643,38 @@ Return the pre-lifted stabilizer matrix for bias-tailored lifted product code of
644643
645644
# Notes
646645
- Use `BiasTailoredLiftedProductCode` to return a quantum code over the base ring directly.
646+
647+
# Example
648+
649+
[[882, 24, d ≤ 24]] BiasTailored Lifted Product Code from Appendix B of [roffe2023bias](@cite).
650+
651+
```jldoctest
652+
julia> F = Oscar.Nemo.Native.GF(2);
653+
654+
julia> S, x = polynomial_ring(F, :x);
655+
656+
julia> l = 63;
657+
658+
julia> R, _ = residue_ring(S, x^l - 1);
659+
660+
julia> A1 = matrix(R, 1, 1, [1 + x^1 + x^6]);
661+
662+
julia> A2 = matrix(R, 7, 7,
663+
[x^36, 0 , 0 , 0 , 0 , 1 , x^9,
664+
x^9 , x^36, 0 , 0 , 0 , 0 , 1 ,
665+
1 , x^9 , x^36, 0 , 0 , 0 , 0 ,
666+
0 , 1 , x^9 , x^36, 0 , 0 , 0 ,
667+
0 , 0 , 1 , x^9 , x^36, 0 , 0 ,
668+
0 , 0 , 0 , 1 , x^9 , x^36, 0 ,
669+
0 , 0 , 0 , 0 , 1 , x^9 , x^36]);
670+
671+
julia> code = BiasTailoredLiftedProductCode(A1, A2);
672+
┌ Warning: Commutativity of A and b required but not yet enforced.
673+
└ @ CodingTheory ~/Desktop/ct/doctests/CodingTheory/src/Quantum/product_codes.jl:60
674+
675+
julia> length(code), dimension(code)
676+
(882, 24)
677+
```
647678
"""
648679
function bias_tailored_lifted_product_matrices(A::MatElem{T}, B::MatElem{T}) where T <: CTGroupAlgebra
649680

@@ -664,7 +695,7 @@ function bias_tailored_lifted_product_matrices(A::MatElem{T}, B::MatElem{T}) whe
664695
A13 = En1 B
665696
A21 = A En2
666697
A24 = Ek1 B_tr
667-
return vcat(hcat(zeros(A21), A12, A13, zeros(A24)), hcat(A21, zeros(A12), zeros(A13), A24))
698+
return vcat(hcat(zero(A21), A12, A13, zero(A24)), hcat(A21, zero(A12), zero(A13), A24))
668699
end
669700

670701
"""

test/Quantum/product_codes_test.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,4 +666,39 @@
666666
@test dimension(Q) == 12
667667
@test_broken minimum_distance(Q) == 10
668668
end
669+
670+
@testset "BiasTailoredLiftedProductCode" begin
671+
# [[882, 24, d ≤ 24]] from Appendix B of https://arxiv.org/pdf/2202.01702
672+
S, x = polynomial_ring(F, :x)
673+
l = 63
674+
R, _ = residue_ring(S, x^l - 1)
675+
A1 = matrix(R, 1, 1, [1 + x^1 + x^6])
676+
A2 = matrix(R, 7, 7,
677+
[x^36, 0 , 0 , 0 , 0 , 1 , x^9,
678+
x^9 , x^36, 0 , 0 , 0 , 0 , 1 ,
679+
1 , x^9 , x^36, 0 , 0 , 0 , 0 ,
680+
0 , 1 , x^9 , x^36, 0 , 0 , 0 ,
681+
0 , 0 , 1 , x^9 , x^36, 0 , 0 ,
682+
0 , 0 , 0 , 1 , x^9 , x^36, 0 ,
683+
0 , 0 , 0 , 0 , 1 , x^9 , x^36])
684+
Q = BiasTailoredLiftedProductCode(A1, A2)
685+
@test length(Q) == 882
686+
@test dimension(Q) == 24
687+
@test_broken minimum_distance(Q) == 24
688+
689+
# [[416, 18, d ≤ 20]] from Example 4.1 of https://arxiv.org/pdf/2202.01702
690+
S, x = polynomial_ring(F, :x)
691+
l = 13
692+
R, _ = residue_ring(S, x^l - 1)
693+
A1 = matrix(R, 4, 4,
694+
[1 , x^11, x^7 , x^12,
695+
x^1 , x^8 , x^2 , x^8 ,
696+
x^11, 1 , x^4 , x^8 ,
697+
x^6 , x^1 , x^4 , x^12,])
698+
A2 = A1
699+
Q = BiasTailoredLiftedProductCode(A1, A2)
700+
@test length(Q) == 416
701+
@test dimension(Q) == 18
702+
@test_broken minimum_distance(Q) == 20
703+
end
669704
end

0 commit comments

Comments
 (0)