-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Feroz <93876775+Fe-r-oz@users.noreply.github.com> Co-authored-by: Fe-r-oz <ferozahmad7cf@gmail.com>
- Loading branch information
1 parent
51b0ecf
commit 615fbe5
Showing
11 changed files
with
166 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""The family of `[[2ʲ, 2ʲ - j - 2, 3]]` Gottesman codes, also known as quantum Hamming codes, as described in [Gottesman's 1997 PhD thesis](@cite gottesman1997stabilizer) and in [gottesman1996class](@cite). | ||
You might be interested in consulting [yu2013all](@cite) and [chao2018quantum](@cite) as well. | ||
The ECC Zoo has an [entry for this family](https://errorcorrectionzoo.org/c/quantum_hamming) | ||
""" | ||
struct Gottesman <: AbstractECC | ||
j::Int | ||
function Gottesman(j) | ||
(j >= 3 && j < 21) || error("In `Gottesman(j)`, `j` must be ≥ 3 in order to obtain a valid code and < 21 to remain tractable") | ||
new(j) | ||
end | ||
end | ||
|
||
code_n(c::Gottesman) = 2^c.j | ||
|
||
function parity_checks(c::Gottesman) | ||
j = c.j | ||
s = j+2 | ||
n = 2^j | ||
|
||
H = zero(Stabilizer, s, n) | ||
for i in 1:n | ||
H[1, i] = (true, false) | ||
H[2, i] = (false, true) | ||
end | ||
for i in 0:n-1 # column of H, corresponds to a single qubit error that is detectable) | ||
Xⁱ = i | ||
Zⁱ = i÷2 | ||
jeven = j%2 == 0 | ||
ieven = i%2 == 0 | ||
if (jeven && ieven) || (!jeven && ieven && i < n÷2) || (!jeven && !ieven && i ≥ n÷2) | ||
Zⁱ = ~Zⁱ | ||
end | ||
for b in 0:j-1 # which check to consider (row of H), also which bit to extract | ||
H[s-b,i+1] = isone((Zⁱ>>b)&0x1), isone((Xⁱ>>b)&0x1) | ||
end | ||
end | ||
H | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Test | ||
using QuantumClifford | ||
using QuantumClifford: mul_left! | ||
using QuantumClifford.ECC | ||
using QuantumClifford.ECC: AbstractECC | ||
|
||
|
||
@testset "Gottesman codes should correct all single-qubit errors" begin | ||
for j in 3:12 | ||
H = parity_checks(Gottesman(j)) | ||
syndromes = Set([]) # the set automatically removes repeated entries | ||
for error_type in (single_x, single_y, single_z) | ||
for bit_index in 1:nqubits(H) | ||
syndrome = comm(H, error_type(nqubits(H), bit_index)) | ||
@test any(==(0x1), syndrome) # checking the syndrome is not trivially zero | ||
push!(syndromes, syndrome) | ||
end | ||
end | ||
@test length(syndromes) == 3*nqubits(H) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
615fbe5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
615fbe5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/103062
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: