Skip to content

Commit

Permalink
simplify circshift (it exists in Base) and do not export (we do not e…
Browse files Browse the repository at this point in the history
…xport the vast majority of classical codes as that would be a too heavy of a commitment to forward stability of features that are not heavily used yet)
  • Loading branch information
Krastanov committed Dec 19, 2024
1 parent 6f6cf9a commit 1048ccf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
6 changes: 3 additions & 3 deletions docs/src/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,13 @@ @article{RevModPhys.87.307
}

@misc{goodenough2024bipartiteentanglementnoisystabilizer,
title={Bipartite entanglement of noisy stabilizer states through the lens of stabilizer codes},
title={Bipartite entanglement of noisy stabilizer states through the lens of stabilizer codes},
author={Kenneth Goodenough and Aqil Sajjad and Eneet Kaur and Saikat Guha and Don Towsley},
year={2024},
eprint={2406.02427},
archivePrefix={arXiv},
primaryClass={quant-ph},
url={https://arxiv.org/abs/2406.02427},
url={https://arxiv.org/abs/2406.02427},
}

@article{panteleev2021degenerate,
Expand Down Expand Up @@ -532,7 +532,7 @@ @article{wang2024coprime
}

@misc{voss2024multivariatebicyclecodes,
title={Multivariate Bicycle Codes},
title={Multivariate Bicycle Codes},
author={Lukas Voss and Sim Jian Xian and Tobias Haug and Kishor Bharti},
year={2024},
eprint={2406.19151},
Expand Down
2 changes: 1 addition & 1 deletion src/ecc/ECC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export parity_checks, parity_checks_x, parity_checks_z, iscss,
code_n, code_s, code_k, rate, distance,
isdegenerate, faults_matrix,
naive_syndrome_circuit, shor_syndrome_circuit, naive_encoding_circuit,
RepCode, LiftedCode, Golay,
RepCode, LiftedCode,
CSS,
Shor9, Steane7, Cleve8, Perfect5, Bitflip3,
Toric, Gottesman, Surface, Concat, CircuitCode, QuantumReedMuller,
Expand Down
19 changes: 7 additions & 12 deletions src/ecc/codes/classical/golay.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ the original parity check matrix `H₂₄`. Thus, all punctured codes are equiva
The ECC Zoo has an [entry for this family](https://errorcorrectionzoo.org/c/golay).
"""
struct Golay <: ClassicalCode
n::Int
n::Int

function Golay(n)
if !(n in (23, 24))
throw(ArgumentError("Invalid parameters: `n` must be either 24 or 23 to obtain a valid code."))
Expand All @@ -31,11 +31,6 @@ struct Golay <: ClassicalCode
end
end

function _circshift_row_golay(row::Vector{Int}, shift::Int, n::Int)
l = length(row)
return [row[mod((i - shift - 1), l) + 1] for i in 1:l]
end

# bordered reverse circulant matrix (see section 1.9.1, pg. 30-33) of [huffman2010fundamentals](@cite).
function _create_A₂₄_golay(n::Int)
A = zeros(Int, n ÷ 2, n ÷ 2)
Expand All @@ -48,19 +43,19 @@ function _create_A₂₄_golay(n::Int)
end
# Fill in the rest of the rows using the reverse circulant property.
for i in 3:n ÷ 2
A[i, 2:end] = _circshift_row_golay(A[i - 1, 2:end], -1, n ÷ 2)
A[i, 1] = 1
A[i, 2:end] = circshift(A[i - 1, 2:end], -1)
A[i, 1] = 1
end
return A
end

function generator(g::Golay)
if g.n == 24
if g.n == 24
A₂₄ = _create_A₂₄_golay(24)
I₁₂ = LinearAlgebra.Diagonal(ones(Int, g.n ÷ 2))
G₂₄ = hcat(I₁₂, (A₂₄)')
return G₂₄
else
else
A₂₄ = _create_A₂₄_golay(24)
A₂₃ = A₂₄[:, 1:end - 1]
I₁₂ = LinearAlgebra.Diagonal(ones(Int, g.n ÷ 2))
Expand All @@ -75,7 +70,7 @@ function parity_checks(g::Golay)
I₁₂ = LinearAlgebra.Diagonal(ones(Int, g.n ÷ 2))
H₂₄ = hcat((A₂₄)', I₁₂)
return H₂₄
else
else
A₂₄ = _create_A₂₄_golay(24)
A₂₃ = A₂₄[:, 1:end - 1]
I₁₂ = LinearAlgebra.Diagonal(ones(Int, g.n ÷ 2))
Expand Down

0 comments on commit 1048ccf

Please sign in to comment.