Skip to content
Draft
Changes from all commits
Commits
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: 5 additions & 0 deletions src/symbolic_cliffords.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Base.@propagate_inbounds setzbit(xzs::AbstractMatrix{T}, r::Int, c::Int, z::T, s
function _apply!(stab::AbstractStabilizer, gate::AbstractSingleQubitOperator; phases::Val{B}=Val(true)) where {B}
s = tab(stab)
c = gate.q
@boundscheck c <= nqubits(stab) || throw(THROW_BOUNDS)
@inbounds @simd for r in eachindex(s)
x = getxbit(s, r, c)
z = getzbit(s, r, c)
Expand All @@ -74,6 +75,7 @@ end
function _apply_inv!(stab::AbstractStabilizer, gate::AbstractSingleQubitOperator; phases::Val{B}=Val(true)) where {B} # code repetition with the corresponding `_apply`
s = tab(stab)
c = gate.q
@boundscheck c <= nqubits(stab) || throw(THROW_BOUNDS)
@inbounds @simd for r in eachindex(s)
x = getxbit(s, r, c)
z = getzbit(s, r, c)
Expand Down Expand Up @@ -176,6 +178,7 @@ end
function _apply!(stab::AbstractStabilizer, op::SingleQubitOperator; phases::Val{B}=Val(true)) where B # TODO Generated functions that simplify the whole `if phases` branch might be a good optimization, but a quick benchmakr comparing sHadamard to SingleQubitOperator(sHadamard) did not show a worthwhile difference.
s = tab(stab)
c = op.q
@boundscheck c <= nqubits(stab) || throw(THROW_BOUNDS)
Tₘₑ = eltype(s.xzs)
sh = getshift(Tₘₑ, c)
xx,zx,xz,zz = Tₘₑ.((op.xx,op.zx,op.xz,op.zz)) .<< sh
Expand Down Expand Up @@ -292,6 +295,7 @@ function _apply!(stab::AbstractStabilizer, gate::AbstractTwoQubitOperator; phase
s = tab(stab)
q1 = gate.q1
q2 = gate.q2
@boundscheck max(q1, q2) <= nqubits(stab) || throw(THROW_BOUNDS)
Tₘₑ = eltype(s.xzs)
shift = getshift(Tₘₑ, q1) - getshift(Tₘₑ, q2)
@inbounds @simd for r in eachindex(s)
Expand All @@ -317,6 +321,7 @@ function _apply_inv!(stab::AbstractStabilizer, gate::AbstractTwoQubitOperator; p
s = tab(stab)
q1 = gate.q1
q2 = gate.q2
@boundscheck max(q1, q2) <= nqubits(stab) || throw(THROW_BOUNDS)
Tₘₑ = eltype(s.xzs)
shift = getshift(Tₘₑ, q1) - getshift(Tₘₑ, q2)
@inbounds @simd for r in eachindex(s)
Expand Down
Loading