diff --git a/src/QuantumClifford.jl b/src/QuantumClifford.jl index d54ec03b6..ce87adab6 100644 --- a/src/QuantumClifford.jl +++ b/src/QuantumClifford.jl @@ -758,10 +758,19 @@ function comm!(v, l::PauliOperator, r::Tableau) v end comm!(v, l::Tableau, r::PauliOperator) = comm!(v, r, l) -@inline comm!(v, l::PauliOperator, r::Stabilizer, i::Int) = comm!(v, l, tab(r), i) -@inline comm!(v, l::Stabilizer, r::PauliOperator, i::Int) = comm!(v, tab(l), r, i) @inline comm!(v, l::PauliOperator, r::Stabilizer) = comm!(v, l, tab(r)) @inline comm!(v, l::Stabilizer, r::PauliOperator) = comm!(v, tab(l), r) +function comm!(v, l::PauliOperator, r::Tableau, i) + v[i] = comm(l,r,i) + v +end +comm!(v, l::Tableau, r::PauliOperator, i) = comm!(v, r, l, i) +@inline comm!(v, l::PauliOperator, r::Stabilizer, i::Int) = comm!(v, l, tab(r), i) +@inline comm!(v, l::Stabilizer, r::PauliOperator, i::Int) = comm!(v, tab(l), r, i) +function comm!(v, s::Tableau, l::Int, r::Int) + v[l] = comm(s, l, r) + v +end @inline comm!(v, s::Stabilizer, l::Int, r::Int) = comm!(v, tab(s), l, r) diff --git a/src/dense_cliffords.jl b/src/dense_cliffords.jl index 20d2cc305..baec10f6e 100644 --- a/src/dense_cliffords.jl +++ b/src/dense_cliffords.jl @@ -82,7 +82,7 @@ function row_limit(str, limit=50) end digits_subchars = collect("₀₁₂₃₄₅₆₇₈₉") -digits_substr(n,nwidth) = join(([digits_subchars[d+1] for d in reverse(digits(n, pad=nwidth))])) +digits_substr(n::Int,nwidth::Int) = join(([digits_subchars[d+1] for d in reverse(digits(n, pad=nwidth))])) function Base.copy(c::CliffordOperator) CliffordOperator(copy(c.tab)) diff --git a/src/ecc/ECC.jl b/src/ecc/ECC.jl index ed50dba5b..cf2366bbf 100644 --- a/src/ecc/ECC.jl +++ b/src/ecc/ECC.jl @@ -335,8 +335,9 @@ isdegenerate(c::AbstractECC, args...) = isdegenerate(parity_checks(c), args...) isdegenerate(c::AbstractStabilizer, args...) = isdegenerate(stabilizerview(c), args...) function isdegenerate(H::Stabilizer, errors) # Described in https://quantumcomputing.stackexchange.com/questions/27279 - syndromes = comm.((H,), errors) # TODO This can be optimized by having something that always returns bitvectors - return length(Set(syndromes)) != length(errors) + syndromes = map(e -> comm(H,e), errors) # TODO This can be optimized by having something that always returns bitvectors + syndrome_set = Set(syndromes) + return length(syndrome_set) != length(errors) end function isdegenerate(H::Stabilizer, d::Int=1) diff --git a/src/ecc/decoder_pipeline.jl b/src/ecc/decoder_pipeline.jl index d1fbe897f..81fd1af30 100644 --- a/src/ecc/decoder_pipeline.jl +++ b/src/ecc/decoder_pipeline.jl @@ -132,7 +132,7 @@ function evaluate_decoder(d::AbstractSyndromeDecoder, setup::AbstractECCSetup, n physical_noisy_circ, syndrome_bits, n_anc = physical_ECC_circuit(H, setup) encoding_circ = naive_encoding_circuit(H) - preX = [sHadamard(i) for i in n-k+1:n] + preX = sHadamard[sHadamard(i) for i in n-k+1:n] mdH = MixedDestabilizer(H) logX_circ, _, logX_bits = naive_syndrome_circuit(logicalxview(mdH), n_anc+1, last(syndrome_bits)+1) diff --git a/test/test_jet.jl b/test/test_jet.jl index ee8817840..304f3b78c 100644 --- a/test/test_jet.jl +++ b/test/test_jet.jl @@ -1,22 +1,27 @@ @testitem "JET checks" tags=[:jet] begin -using JET -using ArrayInterface -using Static -using Graphs -using StridedViews -using LinearAlgebra + using JET + using Test + using ArrayInterface + using Static + using Graphs + using StridedViews + using LinearAlgebra + using Nemo + using AbstractAlgebra -rep = report_package("QuantumClifford"; - ignored_modules=( - AnyFrameModule(Graphs.LinAlg), - AnyFrameModule(Graphs.SimpleGraphs), - AnyFrameModule(ArrayInterface), - AnyFrameModule(Static), - AnyFrameModule(StridedViews), - AnyFrameModule(LinearAlgebra), - ) -) -@show rep -@test_broken length(JET.get_reports(rep)) == 0 -@test length(JET.get_reports(rep)) <= 23 + rep = report_package("QuantumClifford"; + ignored_modules=( + AnyFrameModule(Graphs.LinAlg), + AnyFrameModule(Graphs.SimpleGraphs), + AnyFrameModule(ArrayInterface), + AnyFrameModule(Static), + AnyFrameModule(StridedViews), + AnyFrameModule(LinearAlgebra), + AnyFrameModule(Nemo), + AnyFrameModule(AbstractAlgebra), + )) + + @show rep + @test_broken length(JET.get_reports(rep)) == 0 + @test length(JET.get_reports(rep)) <= 11 end