Skip to content

Commit 4cc8eac

Browse files
committed
🐞🦋 fix generation of classical LiftedCode and code_n, code_s paras, define code_k
1 parent def729f commit 4cc8eac

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
## v0.10.0 - 2025-06-25
99

10+
- **(fix)** The `parity_checks`, `code_n`, and `code_s` methods were throwing errors and `code_k` was not defined for the classical `LiftedCode`s.
1011
- **(fix)** The gates `SQRTY`, `CXYZ`, `CZYX` were computing phases incorrectly when acting on `I` stabilizers.
1112
- **(fix)** Paulis with imaginary phases had their phases incorrectly tracked.
1213
- **(fix)** `rowdecompose` was not accounting for the phase of the input Pauli string, leading to potential errors in non-Clifford functionality.

ext/QuantumCliffordHeckeExt/QuantumCliffordHeckeExt.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ using QECCore
44
import QECCore: code_n, code_s, code_k, rate, distance
55
using DocStringExtensions
66

7-
import QuantumClifford, LinearAlgebra
7+
import QuantumClifford
8+
import LinearAlgebra
9+
import LinearAlgebra: rank
810
import Hecke: Group, GroupElem, AdditiveGroupElem,
911
GroupAlgebra, GroupAlgebraElem, FqFieldElem, representation_matrix, dim, base_ring,
10-
multiplication_table, coefficients, abelian_group, group_algebra, rand
12+
multiplication_table, coefficients, abelian_group, group_algebra, rand, order, group
1113
import Nemo
12-
import Nemo: characteristic, matrix_repr, GF, ZZ, lift
14+
import Nemo: characteristic, matrix_repr, GF, ZZ, lift, matrix
1315

1416
import QuantumClifford.ECC: iscss, parity_checks,
1517
two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes, check_repr_commutation_relation,
1618
haah_cubic_codes
1719

1820
import QECCore: AbstractECC, CSS,
19-
hgp, code_k, code_n, code_s, parity_matrix_x, parity_matrix_z, parity_matrix_xz
21+
hgp, code_k, code_n, code_s, parity_matrix_x, parity_matrix_z, parity_matrix_xz, parity_matrix
2022

2123
# exported from extension so that Documenter.jl sees them when autogenerating API lists
2224
export hgp, two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes, haah_cubic_codes,

ext/QuantumCliffordHeckeExt/lifted.jl

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,35 @@ function LiftedCode(group_elem_array::Matrix{<: GroupOrAdditiveGroupElem}; GA::G
8383
end
8484
end
8585

86-
# TODO document and doctest example
86+
"""
87+
Constructs a group algebra code over `GF(2)` by lifting a matrix of cyclic shifts
88+
(entries modulo `l`) to the group algebra of the abelian group `ℤ/lℤ` of order `l`.
89+
90+
# Example
91+
92+
```jldoctest
93+
julia> import Hecke; import QuantumClifford.ECC
94+
95+
julia> base_matrix = [0 0 0 0; 0 1 2 5; 0 6 3 1]; l = 3;
96+
97+
julia> c = LiftedCode(base_matrix, l);
98+
99+
julia> parity_checks(c)
100+
9×12 Matrix{Bool}:
101+
1 0 0 1 0 0 1 0 0 1 0 0
102+
0 1 0 0 1 0 0 1 0 0 1 0
103+
0 0 1 0 0 1 0 0 1 0 0 1
104+
1 0 0 0 0 1 0 1 0 0 1 0
105+
0 1 0 1 0 0 0 0 1 0 0 1
106+
0 0 1 0 1 0 1 0 0 1 0 0
107+
1 0 0 1 0 0 1 0 0 0 0 1
108+
0 1 0 0 1 0 0 1 0 1 0 0
109+
0 0 1 0 0 1 0 0 1 0 1 0
110+
111+
julia> code_n(c), code_k(c), code_s(c)
112+
(12, 5, 9)
113+
```
114+
"""
87115
function LiftedCode(shift_array::Matrix{Int}, l::Int; GA::GroupAlgebra=group_algebra(GF(2), abelian_group(l)))
88116
A = zeros(GA, size(shift_array)...)
89117
for i in 1:size(shift_array, 1)
@@ -104,9 +132,11 @@ function concat_lift_repr(repr, mat)
104132
end
105133

106134
function parity_checks(c::LiftedCode)
107-
return lift(c.repr, c.A)
135+
return concat_lift_repr(c.repr, c.A)
108136
end
109137

110-
code_n(c::LiftedCode) = size(c.A, 2) * size(zero(c.GA), 2)
138+
code_n(c::LiftedCode) = size(c.A, 2) * order(group(c.GA))
139+
140+
code_s(c::LiftedCode) = size(c.A, 1) * order(group(c.GA))
111141

112-
code_s(c::LiftedCode) = size(c.A, 1) * size(zero(c.GA), 1)
142+
code_k(c::LiftedCode) = code_n(c) - rank(matrix(GF(2), parity_checks(c)))

src/ecc/ECC.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module ECC
22

33
using QECCore
4-
import QECCore: code_n, code_s, code_k, rate, distance, parity_matrix_x, parity_matrix_z,parity_matrix
4+
import QECCore: code_n, code_s, code_k, rate, distance, parity_matrix_x, parity_matrix_z, parity_matrix
55
using LinearAlgebra: LinearAlgebra, I, rank, tr
66
using QuantumClifford: QuantumClifford, AbstractOperation, AbstractStabilizer,
77
AbstractTwoQubitOperator, Stabilizer, PauliOperator,

0 commit comments

Comments
 (0)