Skip to content

Commit

Permalink
implement sSQRTXX, sInvSQRTXX, sSQRTYY, sInvSQRTYY
Browse files Browse the repository at this point in the history
  • Loading branch information
Fe-r-oz committed Sep 24, 2024
1 parent 05491d9 commit f574c34
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
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, x1z1x2z2, x1x2, x1z2, ~iszero((x1 & ~z1 & x2) | (x1 & ~z1 & ~z2) | (x1 & x2 & ~z2)))
@qubitop2 InvZCrY (x1, x1z1x2z2, x1x2, x1z2, ~iszero((x1 & z1 & ~x2 & ~z2) | (x1 & ~z1 & ~x2 & z2) | (x1 & z1 & ~x2 & z2) | (x1 & z1 & x2 & z2)))

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

@qubitop2 SQRTYY (z1x2z2, x1z2x2, x1z1z2, x1x2z1, ~iszero((~x1 &~z1 & x2 &~z2) | ( x1 &~z1 &~x2 &~z2) | ( x1 &~z1 & x2 & z2) | ( x1 & z1 & x2 &~z2)))
@qubitop2 InvSQRTYY (z1x2z2, x1z2x2, x1z1z2, x1x2z1, ~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

0 comments on commit f574c34

Please sign in to comment.