Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4cc8eac
🐞🦋 fix generation of classical LiftedCode and code_n, code_s paras, …
Fe-r-oz Jun 26, 2025
63bc79d
🔌use parity_matrix instead of parity_checks
Fe-r-oz Jun 26, 2025
112c76a
🧹 polish
Fe-r-oz Jun 26, 2025
5326e26
🔌 polish 2
Fe-r-oz Jun 26, 2025
5883231
🧾 document the other constructor
Fe-r-oz Jun 26, 2025
fb42147
🧹 polish
Fe-r-oz Jun 26, 2025
42e5bfa
🧹 polish doctest
Fe-r-oz Jun 26, 2025
ac1dd49
🧹 add basic tests test_nowarn that just check there is no method erro…
Fe-r-oz Jun 29, 2025
4e241df
🧹 polish
Fe-r-oz Jun 29, 2025
5bbe0f9
Merge branch 'QuantumSavory:master' into fa/fixclassicallpcode
Fe-r-oz Jul 2, 2025
6bcbc41
add changelog
Fe-r-oz Jul 2, 2025
d8de0ce
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Jul 5, 2025
ee22d33
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Jul 6, 2025
da35de0
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Jul 14, 2025
765bf20
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Jul 17, 2025
aa7fceb
use Hecke.group
Fe-r-oz Jul 17, 2025
af40edb
Merge branch 'QuantumSavory:master' into fa/fixclassicallpcode
Fe-r-oz Jul 21, 2025
286c6e0
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Jul 23, 2025
72d51d7
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Jul 24, 2025
01ca06b
use Hecke.group
Fe-r-oz Jul 25, 2025
c225552
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Jul 25, 2025
6098913
merge conflict update
Fe-r-oz Jul 25, 2025
59d71a5
Merge branch 'QuantumSavory:master' into fa/fixclassicallpcode
Fe-r-oz Jul 25, 2025
5cd71fa
merge conflict cleanup
Fe-r-oz Jul 25, 2025
826fd6f
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Aug 9, 2025
1b39d9a
merge conflict cleanup: since code_k is recently defined in QECCore f…
Fe-r-oz Aug 9, 2025
b5d63ca
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Aug 10, 2025
84b9931
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Aug 23, 2025
c8c7230
Merge branch 'QuantumSavory:master' into fa/fixclassicallpcode
Fe-r-oz Aug 26, 2025
58375ce
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Sep 1, 2025
c8ad9d7
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Oct 9, 2025
fa64869
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Oct 28, 2025
52e531b
Merge branch 'master' into fa/fixclassicallpcode
Fe-r-oz Oct 30, 2025
e9fd581
polish
Fe-r-oz Oct 30, 2025
a574142
polish
Fe-r-oz Oct 30, 2025
8bacf0f
add LiftedCode to the CECC tests
Fe-r-oz Oct 30, 2025
0582ce5
add degree
Fe-r-oz Oct 30, 2025
e76180c
add gcd
Fe-r-oz Oct 30, 2025
1e7d4f4
polish 2
Fe-r-oz Oct 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions ext/QuantumCliffordHeckeExt/QuantumCliffordHeckeExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ using QECCore
import QECCore: code_n, code_s, code_k, rate, distance
using DocStringExtensions

import QuantumClifford
import QuantumClifford: gf2_row_echelon_with_pivots!
import LinearAlgebra
import QuantumClifford, LinearAlgebra

import Hecke: Group, GroupElem, AdditiveGroupElem,
GroupAlgebra, GroupAlgebraElem, FqFieldElem, representation_matrix, dim, base_ring,
multiplication_table, coefficients, abelian_group, group_algebra, rand, gens, order,
is_commutative, FqPolyRingElem, residue_ring, coeff, zero_matrix, mod1, lift, ZZ, gen,
matrix, ncols, nrows, degree, EuclideanRingResidueRingElem, quo, parent, zero, gcd,
polynomial_ring, characteristic, isone, mod, factor, zeros
polynomial_ring, characteristic, isone, mod, factor, zeros, group, EuclideanRingResidueRingElem,
degree, gcd, nrows, ncols
import Hecke.Generic.MatSpaceElem
import Nemo
import Nemo: characteristic, matrix_repr, GF, ZZ, lift, rank
import Nemo: characteristic, matrix_repr, GF, ZZ, lift, matrix, rank

import QuantumClifford.ECC: iscss, parity_checks,
import QuantumClifford.ECC: iscss, parity_checks, parity_matrix,
two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes, check_repr_commutation_relation,
haah_cubic_codes, honeycomb_color_codes, check_repr_regular_linear, random_qc_ghp_code_matrix_A

import QECCore: AbstractQECC, CSS, AbstractCSSCode,
hgp, code_k, code_n, code_s, parity_matrix_x, parity_matrix_z, parity_matrix_xz
hgp, code_k, code_n, code_s, parity_matrix_x, parity_matrix_z, parity_matrix_xz, parity_matrix

import Random
import Random: AbstractRNG, default_rng, randperm
Expand Down
79 changes: 73 additions & 6 deletions ext/QuantumCliffordHeckeExt/lifted.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,44 @@ function LiftedCode(A::Matrix{GroupAlgebraElem{FqFieldElem, <: GroupAlgebra}}; G
LiftedCode(A; GA=GA, repr=representation_matrix)
end

# TODO document and doctest example
"""
Constructs a group algebra code by embedding a matrix of group elements into the
specified group algebra `GA`, with optional custom representation `repr`.

# Example

```jldoctest
julia> import Hecke: group_algebra, GF, abelian_group, gens, representation_matrix

julia> import QuantumClifford.ECC: LiftedCode, code_n, code_k, code_s

julia> import QuantumClifford.ECC.QECCore: parity_matrix

julia> l = 12; GA = group_algebra(GF(2), abelian_group(l)); x = gens(GA)[];

julia> B = reshape([1 + x + x^3 + x^6], (1, 1));

julia> c = LiftedCode(B, repr = representation_matrix);

julia> code = parity_matrix(c)
12×12 Matrix{Bool}:
1 0 0 0 0 0 1 0 0 1 0 1
1 1 0 0 0 0 0 1 0 0 1 0
0 1 1 0 0 0 0 0 1 0 0 1
1 0 1 1 0 0 0 0 0 1 0 0
0 1 0 1 1 0 0 0 0 0 1 0
0 0 1 0 1 1 0 0 0 0 0 1
1 0 0 1 0 1 1 0 0 0 0 0
0 1 0 0 1 0 1 1 0 0 0 0
0 0 1 0 0 1 0 1 1 0 0 0
0 0 0 1 0 0 1 0 1 1 0 0
0 0 0 0 1 0 0 1 0 1 1 0
0 0 0 0 0 1 0 0 1 0 1 1

julia> code_n(c), code_k(c), code_s(c)
(12, 3, 12)
```
"""
function LiftedCode(group_elem_array::Matrix{<: GroupOrAdditiveGroupElem}; GA::GroupAlgebra=group_algebra(GF(2), parent(group_elem_array[1,1])), repr::Union{Function, Nothing}=nothing)
A = zeros(GA, size(group_elem_array)...)
for i in axes(group_elem_array, 1), j in axes(group_elem_array, 2)
Expand All @@ -83,7 +120,37 @@ function LiftedCode(group_elem_array::Matrix{<: GroupOrAdditiveGroupElem}; GA::G
end
end

# TODO document and doctest example
"""
Constructs a group algebra code over `GF(2)` by lifting a matrix of cyclic shifts
(entries modulo `l`) to the group algebra of the abelian group `ℤ/lℤ` of order `l`.

# Example

```jldoctest
julia> import Hecke; import QuantumClifford.ECC: LiftedCode, code_n, code_k, code_s

julia> import QuantumClifford.ECC.QECCore: parity_matrix

julia> base_matrix = [0 0 0 0; 0 1 2 5; 0 6 3 1]; l = 3;

julia> c = LiftedCode(base_matrix, l);

julia> code = parity_matrix(c)
9×12 Matrix{Bool}:
1 0 0 1 0 0 1 0 0 1 0 0
0 1 0 0 1 0 0 1 0 0 1 0
0 0 1 0 0 1 0 0 1 0 0 1
1 0 0 0 0 1 0 1 0 0 1 0
0 1 0 1 0 0 0 0 1 0 0 1
0 0 1 0 1 0 1 0 0 1 0 0
1 0 0 1 0 0 1 0 0 0 0 1
0 1 0 0 1 0 0 1 0 1 0 0
0 0 1 0 0 1 0 0 1 0 1 0

julia> code_n(c), code_k(c), code_s(c)
(12, 5, 9)
```
"""
function LiftedCode(shift_array::Matrix{Int}, l::Int; GA::GroupAlgebra=group_algebra(GF(2), abelian_group(l)), repr=representation_matrix)
A = zeros(GA, size(shift_array)...)
for i in 1:size(shift_array, 1)
Expand All @@ -103,10 +170,10 @@ function concat_lift_repr(repr, mat)
return z
end

function parity_checks(c::LiftedCode)
return lift(c.repr, c.A)
function parity_matrix(c::LiftedCode)
return concat_lift_repr(c.repr, c.A)
end

code_n(c::LiftedCode) = size(c.A, 2) * size(zero(c.GA), 2)
code_n(c::LiftedCode) = size(c.A, 2) * order(group(c.GA))

code_s(c::LiftedCode) = size(c.A, 1) * size(zero(c.GA), 1)
code_s(c::LiftedCode) = size(c.A, 1) * order(group(c.GA))
4 changes: 2 additions & 2 deletions ext/QuantumCliffordOscarExt/bivariate_bicycle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ We consider the specific ideal generated by two polynomials enforcing periodic b

```math
\\begin{aligned}
J = \\langle x^\\ell - 1, y^m - 1 \\rangle = { p(x,y)(x^\ell - 1) + q(x,y)(y^m - 1) \\mid p, q \\in \\mathbb{F}_2[x,y]}
J = \\langle x^\\ell - 1, y^m - 1 \\rangle = { p(x,y)(x^\\ell - 1) + q(x,y)(y^m - 1) \\mid p, q \\in \\mathbb{F}_2[x,y]}
\\end{aligned}
```

Expand All @@ -37,7 +37,7 @@ conditions in the y-direction.

Formally, to verify that ``J`` satisfies the *ideal* requirements, the properties of J are as follows:

- ``(J, +) \\leq mathbb{F}_2[x, y], +)``
- ``(J, +) \\leq \\mathbb{F}_2[x, y], +)``

For any ``f(x,y) \\in \\mathbb{F}_2[x, y]`` and any ``j(x,y) \\in J``:
- ``f(x,y) \\cdot j(x,y) \\in J``
Expand Down
1 change: 1 addition & 0 deletions test/test_cecc.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@testitem "ECC" tags=[:ecc, :ecc_base] begin
using Nemo
using Hecke
using QuantumClifford.ECC
using QuantumClifford.ECC: AbstractCECC, QECCore

Expand Down
11 changes: 10 additions & 1 deletion test/test_cecc_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using InteractiveUtils
using SparseArrays

import Nemo: GF, matrix, rank, finite_field, polynomial_ring
import Hecke: group_algebra, abelian_group, gens, representation_matrix
import LinearAlgebra

include("test_ecc_base.jl")
Expand Down Expand Up @@ -40,6 +41,13 @@ R, z = polynomial_ring(F, :z)
g₄ = z^2 + α^7*z + 1
L₄ = [α^i for i in 2:13]

# Lifted Codes
l₁ = 12; GA₁ = group_algebra(GF(2), abelian_group(l)); x = gens(GA)[]
B₁ = reshape([1 + x + x^3 + x^6], (1, 1))
c = LiftedCode(B, repr = representation_matrix)

base_matrix₂ = [0 0 0 0; 0 1 2 5; 0 6 3 1]; l₂ = 3;

const classical_code_instance_args = Dict(
:RepCode => [3, 4, 5, 6, 7, 8, 9, 10],
:BCH => [(3, 1), (3, 2), (4, 1), (4, 1), (5, 1), (5, 2), (6, 1), (6, 2)],
Expand All @@ -48,7 +56,8 @@ const classical_code_instance_args = Dict(
:Golay => [(23), (24)],
:Hamming => [2, 3, 4, 5, 6, 7, 8],
:GallagerLDPC => [(3, 3, 4), (3, 4, 5), (4, 5, 7), (4, 6, 7)],
:GoppaCode => [(m₁, t₁, g₁, L₁), (m₂, t₂, g₂), (m₃, t₃, g₃), (m₄, t₄, g₄, L₄)]
:GoppaCode => [(m₁, t₁, g₁, L₁), (m₂, t₂, g₂), (m₃, t₃, g₃), (m₄, t₄, g₄, L₄)],
:LiftedCode => [(B₁, repr = representation_matrix), (base_matrix₂, l₂), (base_matrix₂, 5), (base_matrix₂, 7)]
)

function all_testable_classical_code_instances(; maxn=nothing)
Expand Down
18 changes: 17 additions & 1 deletion test/test_ecc_throws.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@testitem "ECC throws" tags=[:ecc, :ecc_base] begin

using QuantumClifford.ECC: ReedMuller, BCH, RecursiveReedMuller, Golay, Triangular488, Triangular666, Hamming
using Hecke
using Hecke: group_algebra, GF, abelian_group, gens, one, representation_matrix
using QuantumClifford.ECC: ReedMuller, BCH, RecursiveReedMuller, Golay, Triangular488, Triangular666, Hamming, LiftedCode, code_k, code_n, code_s, parity_matrix

@test_throws ArgumentError ReedMuller(-1, 3)
@test_throws ArgumentError ReedMuller(1, 0)
Expand All @@ -26,4 +28,18 @@
@test_throws ArgumentError Triangular488(1)
@test_throws ArgumentError Triangular666(8)
@test_throws ArgumentError Triangular666(1)

l = 12; GA = group_algebra(GF(2), abelian_group(l)); x = gens(GA)[]
B = reshape([1 + x + x^3 + x^6], (1, 1))
c = LiftedCode(B, repr = representation_matrix)
@test_nowarn parity_matrix(c)
@test_nowarn code_n(c)
@test_nowarn code_k(c)
@test_nowarn code_s(c)
base_matrix = [0 0 0 0; 0 1 2 5; 0 6 3 1]; l = 3;
c = LiftedCode(base_matrix, l);
@test_nowarn parity_matrix(c)
@test_nowarn code_n(c)
@test_nowarn code_k(c)
@test_nowarn code_s(c)
end
Loading