Skip to content

Commit d312a37

Browse files
committed
bivariate bicycle code using polynomial quotient ring
1 parent aeb1545 commit d312a37

File tree

5 files changed

+579
-2
lines changed

5 files changed

+579
-2
lines changed

ext/QuantumCliffordOscarExt/QuantumCliffordOscarExt.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import Oscar: free_group, small_group_identification, describe, order, FPGroupEl
1717
base_ring, ComplexOfMorphisms, coefficients, zero_matrix, hcat, circshift, size, zeros, enumerate,
1818
kronecker_product, FqMatrix, identity_matrix, iszero, FqPolyRingElem, laurent_polynomial_ring,
1919
hnf_with_transform, ideal, intersect, ==, is_coprime, quo, groebner_basis, length, FqMPolyRingElem,
20-
first, length, MPolyQuoRingElem, FqMPolyRingElem, modulus, ideal, monomials, terms, coeff, degree, mod
20+
first, MPolyQuoRingElem, FqMPolyRingElem, modulus, ideal, monomials, terms, coeff, degree, mod,
21+
monomial, exponent_vector, nvars
2122
import Oscar.Generic.MatSpaceElem
2223
import Oscar.Generic.DirectSumModule
2324
import Oscar.Generic.LaurentMPolyWrap
@@ -37,6 +38,7 @@ export twobga_from_direct_product, twobga_from_fp_group, DDimensionalSurfaceCode
3738

3839
include("types.jl")
3940
include("direct_product.jl")
41+
include("bivariate_bicycle.jl")
4042
include("generalized_toric.jl")
4143
include("group_presentation.jl")
4244
include("d_dimensional_codes.jl")
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""
2+
Bivariate Bicycle code using *polynomial quotient ring formalism*: The set of
3+
monomials ``\\{x^i y^j \\mid 0 \\leq i < \\ell, 0 \\leq j < m}`` forms a basis
4+
for the matrix algebra generated by ``x`` and ``y``, establishing a [bijection](https://en.wikipedia.org/wiki/Bijection)
5+
between these monomials and the resulting ``(\\ell m) \\times (\\ell m)`` matrices.
6+
This correspondence allows us to work equivalently with either the polynomial or
7+
matrix formulation [wang2024coprime](@cite).
8+
"""
9+
struct BivariateBicycleCode <: AbstractCSSCode
10+
"""Order of the first abelian group in ``\\mathbb{F}_2[\\mathbb{Z}_\\ell \\times \\mathbb{Z}_m]``"""
11+
::Int
12+
"""Order of the second abelian group in ``\\mathbb{F}_2[\\mathbb{Z}_\\ell \\times \\mathbb{Z}_m]``"""
13+
m::Int
14+
"""First bivariate polynomial in quotient ring ``\\frac{\\mathbb{F}_2[x, y]}{\\langle x^\\ell-1, y^m-1 \\rangle}``"""
15+
c::MPolyQuoRingElem
16+
"""Second bivariate polynomial in quotient ring ``\\frac{\\mathbb{F}_2[x, y]}{\\langle x^\\ell-1, y^m-1 \\rangle}``"""
17+
d::MPolyQuoRingElem
18+
19+
function BivariateBicycleCode(ℓ::Int, m::Int, c::MPolyQuoRingElem, d::MPolyQuoRingElem)
20+
> 0 || throw(ArgumentError("ℓ must be positive"))
21+
m > 0 || throw(ArgumentError("m must be positive"))
22+
parent(c) == parent(d) || throw(ArgumentError("Polynomials must be in the same quotient ring"))
23+
Q = parent(c)
24+
R = base_ring(Q)
25+
base_ring(R) == GF(2) || throw(ArgumentError("Base ring must be GF(2)"))
26+
nvars(R) == 2 || throw(ArgumentError("Must be bivariate polynomials"))
27+
new(ℓ, m, c, d)
28+
end
29+
end
30+
31+
function poly_to_coeff_mat(poly::MPolyQuoRingElem, ℓ::Int, m::Int)
32+
mat = zeros(Int, ℓ, m)
33+
poly_lift = lift(poly)
34+
for term in terms(poly_lift)
35+
coeffᵥₐₗ = coeff(term, 1)
36+
coeffᵢₙₜ = iszero(coeffᵥₐₗ) ? 0 : 1
37+
monom = monomial(term, 1)
38+
exps = exponent_vector(monom, 1)
39+
i = length(exps) >= 1 ? exps[1] : 0
40+
j = length(exps) >= 2 ? exps[2] : 0
41+
i = mod(i, ℓ)
42+
j = mod(j, m)
43+
if i <&& j < m
44+
mat[i+1, j+1] = coeffᵢₙₜ
45+
end
46+
end
47+
return mat
48+
end
49+
50+
function build_bivariate_circulant(coeff_mat::Matrix{Int})
51+
ℓ, m = size(coeff_mat)
52+
n =*m
53+
circ_mat = zeros(Int, n, n)
54+
for i₁ in 0:-1, j₁ in 0:m-1
55+
row_idx = i₁*m+j₁+1
56+
for i₂ in 0:-1, j₂ in 0:m-1
57+
i_res = mod(i₁ + i₂, ℓ)
58+
j_res = mod(j₁ + j₂, m)
59+
col_idx = i_res*m + j_res + 1
60+
circ_mat[row_idx, col_idx] += coeff_mat[i₂+1, j₂+1]
61+
end
62+
end
63+
return circ_mat
64+
end
65+
66+
function parity_matrix_xz(c::BivariateBicycleCode)
67+
A_coeff = poly_to_coeff_mat(c.c, c.ℓ, c.m)
68+
B_coeff = poly_to_coeff_mat(c.d, c.ℓ, c.m)
69+
A = build_bivariate_circulant(A_coeff)
70+
B = build_bivariate_circulant(B_coeff)
71+
hx, hz = hcat(A, B), hcat(transpose(B), transpose(A))
72+
return hx, hz
73+
end
74+
75+
parity_matrix_x(c::BivariateBicycleCode) = parity_matrix_xz(c)[1]
76+
77+
parity_matrix_z(c::BivariateBicycleCode) = parity_matrix_xz(c)[2]
78+
79+
code_n(c::BivariateBicycleCode) = 2*c.*c.m

src/ecc/ECC.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export parity_checks, parity_matrix_x, parity_matrix_z, iscss,
4141
GeneralizedCirculantBivariateBicycle, GeneralizedHyperGraphProductCode,
4242
GeneralizedBicycleCode, ExtendedGeneralizedBicycleCode,
4343
HomologicalProductCode, DoubleHomologicalProductCode,
44-
GeneralizedToricCode, TrivariateTricycleCode,
44+
GeneralizedToricCode, TrivariateTricycleCode, BivariateBicycleCode,
4545
evaluate_decoder,
4646
CommutationCheckECCSetup, NaiveSyndromeECCSetup, ShorSyndromeECCSetup,
4747
TableDecoder,

src/ecc/codes/qeccs_using_oscar.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,13 @@ function TrivariateTricycleCode(args...; kwargs...)
7474
end
7575
return ext.TrivariateTricycleCode(args...; kwargs...)
7676
end
77+
78+
"""Bivariate Bicycle codes ([jacob2025singleshotdecodingfaulttolerantgates](@cite))
79+
Implemented as a package extension with `Oscar`. Check the [QuantumClifford documentation](http://qc.quantumsavory.org/stable/ECC_API/) for more details on that extension."""
80+
function BivariateBicycleCode(args...; kwargs...)
81+
ext = Base.get_extension(QuantumClifford, :QuantumCliffordOscarExt)
82+
if isnothing(ext)
83+
throw("The `BivariateBicycleCode` depends on the package `Oscar` but you have not installed or imported it yet. Immediately after you import `Oscar`, the `BivariateBicycleCode` will be available.")
84+
end
85+
return ext.BivariateBicycleCode(args...; kwargs...)
86+
end

0 commit comments

Comments
 (0)