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

implement sSQRTXX, sInvSQRTXX, sSQRTYY, sInvSQRTYY #368

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/QuantumClifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export
sHadamardXY, sHadamardYZ, sSQRTX, sInvSQRTX, sSQRTY, sInvSQRTY, sCXYZ, sCZYX,
sCNOT, sCPHASE, sSWAP,
sXCX, sXCY, sXCZ, sYCX, sYCY, sYCZ, sZCX, sZCY, sZCZ,
sZCrY, sInvZCrY,
sZCrY, sInvZCrY, sSQRTXX, sInvSQRTXX, sSQRTYY, sInvSQRTYY,
# Misc Ops
SparseGate,
sMX, sMY, sMZ, PauliMeasurement, Reset, sMRX, sMRY, sMRZ,
Expand Down
10 changes: 10 additions & 0 deletions src/symbolic_cliffords.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ end
@qubitop2 ZCrY (x1, x1⊻z1⊻x2⊻z2, x1⊻x2, x1⊻z2, ~iszero((x1 & ~z1 & x2) | (x1 & ~z1 & ~z2) | (x1 & x2 & ~z2)))
@qubitop2 InvZCrY (x1, x1⊻z1⊻x2⊻z2, x1⊻x2, x1⊻z2, ~iszero((x1 & z1 & ~x2 & ~z2) | (x1 & ~z1 & ~x2 & z2) | (x1 & z1 & ~x2 & z2) | (x1 & z1 & x2 & z2)))

@qubitop2 SQRTXX (z1⊻z2⊻x1, z1 , z1⊻x2⊻z2, z2 , ~iszero((~x1 & z1 &~z2) | ( ~z1 &~x2 & z2)))
@qubitop2 InvSQRTXX (z1⊻z2⊻x1, z1 , z1⊻x2⊻z2, z2 , ~iszero((x1 & z1 & ~z2) | ( ~z1 & x2 & z2)))

@qubitop2 SQRTYY (z1⊻x2⊻z2, x1⊻z2⊻x2, x1⊻z1⊻z2, x1⊻x2⊻z1, ~iszero((~x1 &~z1 & x2 &~z2) | ( x1 &~z1 &~x2 &~z2) | ( x1 &~z1 & x2 & z2) | ( x1 & z1 & x2 &~z2)))
@qubitop2 InvSQRTYY (z1⊻x2⊻z2, x1⊻z2⊻x2, x1⊻z1⊻z2, x1⊻x2⊻z1, ~iszero(( x1 & z1 &~x2 & z2) | (~x1 & z1 & x2 & z2) | (~x1 & z1 &~x2 &~z2) | (~x1 &~z1 &~x2 & z2)))

#=
To get the boolean formulas for the phase, it is easiest to first write down the truth table for the phase:
for i in 0:15
Expand Down Expand Up @@ -384,6 +390,10 @@ LinearAlgebra.inv(op::sYCY) = sYCY(op.q1, op.q2)
LinearAlgebra.inv(op::sYCZ) = sYCZ(op.q1, op.q2)
LinearAlgebra.inv(op::sZCrY) = sInvZCrY(op.q1, op.q2)
LinearAlgebra.inv(op::sInvZCrY) = sZCrY(op.q1, op.q2)
LinearAlgebra.inv(op::sSQRTXX) = sInvSQRTXX(op.q1, op.q2)
LinearAlgebra.inv(op::sInvSQRTXX) = sSQRTXX(op.q1, op.q2)
LinearAlgebra.inv(op::sSQRTYY) = sInvSQRTYY(op.q1, op.q2)
LinearAlgebra.inv(op::sInvSQRTYY) = sSQRTYY(op.q1, op.q2)

##############################
# Functions that perform direct application of common operators without needing an operator instance
Expand Down
9 changes: 9 additions & 0 deletions test/test_symcliff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
@test CliffordOperator(inv(random_op), i) == inv(CliffordOperator(random_op, i))
@test CliffordOperator(inv(SingleQubitOperator(random_op)), i) == inv(CliffordOperator(random_op, i))
end
end

@testset "Consistency checks with Stim" begin
# see https://github.com/quantumlib/Stim/blob/main/doc/gates.md
Expand All @@ -101,4 +102,12 @@
@test CliffordOperator(inv(sInvZCrY(n₁, n₂)), n₁) == inv(CliffordOperator(sInvZCrY(n₁, n₂), n₁))
end
end

@testset "Consistency check with STIM conventions" begin
# see https://github.com/quantumlib/Stim/blob/main/doc/gates.md
@test CliffordOperator(sSQRTXX) == C"XI IX -YX -XY"
@test CliffordOperator(sInvSQRTXX) == C"XI IX YX XY"
@test CliffordOperator(sSQRTYY) == C"-ZY -YZ XY YX"
@test CliffordOperator(sInvSQRTYY) == C"ZY YZ -XY -YX"
end
end
Loading