diff --git a/src/QuantumClifford.jl b/src/QuantumClifford.jl index 6b4945b6b..36901ed23 100644 --- a/src/QuantumClifford.jl +++ b/src/QuantumClifford.jl @@ -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, diff --git a/src/symbolic_cliffords.jl b/src/symbolic_cliffords.jl index 03f5f2e69..fcff4cb38 100644 --- a/src/symbolic_cliffords.jl +++ b/src/symbolic_cliffords.jl @@ -339,6 +339,12 @@ end @qubitop2 SQRTZZ (x1 , x1⊻x2⊻z1 , x2 , x1⊻z2⊻x2 , ~iszero((x1 & z1 & ~x2) | (~x1 & x2 & z2))) @qubitop2 InvSQRTZZ (x1 , x1⊻x2⊻z1 , x2 , x1⊻z2⊻x2 , ~iszero((x1 &~z1 & ~x2) | (~x1 & 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 @@ -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 diff --git a/test/test_symcliff.jl b/test/test_symcliff.jl index 40ed505ac..6bbad80d4 100644 --- a/test/test_symcliff.jl +++ b/test/test_symcliff.jl @@ -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 @@ -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