Skip to content

Commit

Permalink
implement sSQRTXX, sInvSQRTXX, sSQRTYY, sInvSQRTYY (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fe-r-oz authored Nov 2, 2024
1 parent d3f42d2 commit c3546cd
Show file tree
Hide file tree
Showing 3 changed files with 16 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 @@ -52,7 +52,7 @@ export
sCNOT, sCPHASE, sSWAP,
sXCX, sXCY, sXCZ, sYCX, sYCY, sYCZ, sZCX, sZCY, sZCZ,
sZCrY, sInvZCrY, sSWAPCX, sInvSWAPCX, sCZSWAP, sCXSWAP, sISWAP, sInvISWAP,
sSQRTZZ, sInvSQRTZZ,
sSQRTZZ, sInvSQRTZZ, 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 @@ -339,6 +339,12 @@ end
@qubitop2 SQRTZZ (x1 , x1x2z1 , x2 , x1z2x2 , ~iszero((x1 & z1 & ~x2) | (~x1 & x2 & z2)))
@qubitop2 InvSQRTZZ (x1 , x1x2z1 , x2 , x1z2x2 , ~iszero((x1 &~z1 & ~x2) | (~x1 & 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 @@ -405,6 +411,10 @@ LinearAlgebra.inv(op::sISWAP) = sInvISWAP(op.q1, op.q2)
LinearAlgebra.inv(op::sInvISWAP) = sISWAP(op.q1, op.q2)
LinearAlgebra.inv(op::sSQRTZZ) = sInvSQRTZZ(op.q1, op.q2)
LinearAlgebra.inv(op::sInvSQRTZZ) = sSQRTZZ(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
5 changes: 5 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 Down Expand Up @@ -113,5 +114,9 @@
@test CliffordOperator(sInvISWAP) == C"-ZY -YZ IZ ZI"
@test CliffordOperator(sSQRTZZ) == C"YZ ZY ZI IZ"
@test CliffordOperator(sInvSQRTZZ) == C"-YZ -ZY ZI IZ"
@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 c3546cd

Please sign in to comment.