Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding iscss for issue #222 #241

Merged
merged 43 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4dbc3fa
adding iscss
Mar 18, 2024
0bb6ad7
updating changelog
Mar 18, 2024
3942a72
adding iscss function
Mar 18, 2024
0c6a646
multimethods
Mar 18, 2024
0274e62
changes
Mar 18, 2024
d1b1e2f
function iscss
Mar 18, 2024
e199ac2
iscss function
Mar 18, 2024
7d2cad8
iscss function
Mar 18, 2024
7d940b7
iscss function
Mar 18, 2024
9a10fd1
iscss function
Mar 18, 2024
baa6538
iscss function
Mar 18, 2024
490ae99
iscss function
Mar 19, 2024
75864d7
iscss function
Mar 19, 2024
a9b14fd
iscss function
Mar 19, 2024
c39abd0
iscss function
Mar 19, 2024
624f5e8
iscss function
Mar 19, 2024
664dc1b
iscss function
Mar 19, 2024
ce63f8e
iscss function
Mar 19, 2024
d52b2b6
iscss function
Mar 19, 2024
80e5693
iscss function
Mar 19, 2024
db6ff0f
iscss function
Mar 19, 2024
074bc47
iscss function
Mar 19, 2024
cfed1ee
iscss function
Mar 19, 2024
4f43dc2
iscss function
Mar 19, 2024
f82a018
iscss function
Mar 19, 2024
4411b85
adding iscss function
Mar 19, 2024
e7d171f
Update test/test_iscss.jl
Fe-r-oz Mar 19, 2024
a62aa4f
adding iscss function
Mar 19, 2024
033fff5
adding iscss function
Mar 19, 2024
5c2e7b6
adding iscss function
Mar 19, 2024
e742b75
adding iscss function
Mar 19, 2024
c674273
Update src/ecc/codes/clevecode.jl
Fe-r-oz Mar 19, 2024
b03ed6a
Merge branch 'master' into isCSS
Fe-r-oz Mar 19, 2024
ccc51fd
Update CHANGELOG.md
Fe-r-oz Mar 19, 2024
9dadece
Update test_ecc_iscss.jl
Fe-r-oz Mar 19, 2024
a84a6b2
Update fivequbit.jl
Fe-r-oz Mar 19, 2024
460a489
Update gottesman.jl
Fe-r-oz Mar 19, 2024
43b3ce8
Update CHANGELOG.md
Fe-r-oz Mar 19, 2024
56e1705
Update test_ecc_iscss.jl
Fe-r-oz Mar 20, 2024
e966c1c
Update test_ecc_iscss.jl
Fe-r-oz Mar 20, 2024
a8ed100
Update test_ecc_iscss.jl
Fe-r-oz Mar 20, 2024
063b417
Update test_ecc_iscss.jl
Fe-r-oz Mar 20, 2024
6eabd9c
Update CHANGELOG.md
Krastanov Mar 20, 2024
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

# News

## v0.9.1 - 2024-03-20

- Implemented `iscss` function to identify whether a given code is known to be a CSS (Calderbank-Shor-Steane) code.

## v0.9.0 - 2024-03-19

- **(breaking)** The defaults in `random_pauli` are now `realphase=true` and `nophase=true`.
Expand All @@ -13,7 +17,6 @@
- Implement an inplace `random_pauli!`, a non-allocating alternative to `random_pauli`.
- Significant improvement in the performance of the ECC decoder pipeline (but many low-hanging fruits still remain).


## v0.8.21 - 2024-03-17

- Implemented the Gottesman code family, also known as [[2^j, 2^j - j - 2, 3]] quantum Hamming codes.
Expand Down
10 changes: 9 additions & 1 deletion src/ecc/ECC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using Nemo: ZZ, residue_ring, matrix

abstract type AbstractECC end

export parity_checks, parity_checks_x, parity_checks_z,
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,
Expand Down Expand Up @@ -49,6 +49,14 @@ function parity_checks_z(code::AbstractECC)
throw(lazy"Codes of type $(typeof(code)) do not have separate X and Z parity checks, either because they are not a CSS code and thus inherently do not have separate checks, or because its separate checks are not yet implemented in this library.")
end

function iscss(::Type{T}) where T<:AbstractECC
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
return false
end

function iscss(c::AbstractECC)
return iscss(typeof(c))
end

parity_checks(s::Stabilizer) = s
Stabilizer(c::AbstractECC) = parity_checks(c)
MixedDestabilizer(c::AbstractECC; kwarg...) = MixedDestabilizer(Stabilizer(c); kwarg...)
Expand Down
4 changes: 4 additions & 0 deletions src/ecc/codes/bitflipcode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ struct Bitflip3 <: AbstractECC end

code_n(c::Bitflip3) = 3

function iscss(::Type{Bitflip3})
return true
end

parity_checks(c::Bitflip3) = S"_ZZ
Z_Z"
4 changes: 4 additions & 0 deletions src/ecc/codes/css.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ struct CSS <: AbstractECC
end
end

function iscss(::Type{CSS})
return true
end

function parity_checks(c::CSS)
extended_Hx = Matrix{Bool}(vcat(c.Hx, zeros(size(c.Hz))))
extended_Hz = Matrix{Bool}(vcat(zeros(size(c.Hx)), c.Hz))
Expand Down
4 changes: 4 additions & 0 deletions src/ecc/codes/shorcode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ struct Shor9 <: AbstractECC end

code_n(c::Shor9) = 9

function iscss(::Type{Shor9})
return true
end

parity_checks(c::Shor9) = S"ZZ_______
_ZZ______
___ZZ____
Expand Down
4 changes: 4 additions & 0 deletions src/ecc/codes/steanecode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

struct Steane7 <: AbstractECC end

function iscss(::Type{Steane7})
return true
end

parity_checks(c::Steane7) = S"___XXXX
_XX__XX
X_X_X_X
Expand Down
4 changes: 4 additions & 0 deletions src/ecc/codes/toric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ struct Toric <: AbstractECC
dz::Int
end

function iscss(::Type{Toric})
return true
end

code_n(c::Toric) = 2*c.dx*c.dz

function parity_checks_xz(c::Toric)
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ end
@doset "ecc_encoding"
@doset "ecc_syndromes"
@doset "ecc_gottesman"
@doset "ecc_iscss"
@doset "precompile"
@doset "pauliframe"
@doset "allocations"
Expand Down
27 changes: 27 additions & 0 deletions test/test_ecc_iscss.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Test
using QuantumClifford
using QuantumClifford.ECC
using QuantumClifford.ECC: AbstractECC

function is_css_matrix(H)
nrows, ncols = size(H)
for i in 1:nrows
has_x = false
has_z = false
for j in 1:ncols
has_x |= H[i,j][1]
has_z |= H[i,j][2]
has_x && has_z && return false
end
end
return true
end

known_all_codes = [Shor9(), Steane7(), Gottesman(3), Cleve8(), Perfect5(), Toric(8,8), CSS([0 1 1 0; 1 1 0 0], [1 1 1 1]), Bitflip3()]

@testset "is CSS" begin
for code in known_all_codes
H = parity_checks(code)
@test iscss(code) == is_css_matrix(H)
end
end
Loading