Skip to content

Commit adc4eb2

Browse files
committed
complete single-qubit
1 parent f1f22ab commit adc4eb2

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

src/QuantumClifford.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export
5353
# Symbolic Clifford Ops
5454
AbstractSymbolicOperator, AbstractSingleQubitOperator, AbstractTwoQubitOperator,
5555
sHadamard, sPhase, sInvPhase, SingleQubitOperator, sId1, sX, sY, sZ,
56-
sHadamardXY, sHadamardYZ, sSQRTX, sInvSQRTX, sSQRTY, sInvSQRTY, sCXYZ, sCZYX,
56+
sHadamardXY, sHadamardYZ, sSQRTX, sInvSQRTX, sSQRTY, sInvSQRTY, sSQRTZ, sInvSQRTZ, sCXYZ, sCZYX,
5757
sCNOT, sCPHASE, sSWAP,
5858
sXCX, sXCY, sXCZ, sYCX, sYCY, sYCZ, sZCX, sZCY, sZCZ,
5959
sZCrY, sInvZCrY, sSWAPCX, sInvSWAPCX, sCZSWAP, sCXSWAP, sISWAP, sInvISWAP,

src/apply_right.jl

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@ function apply_right!(l::CliffordOperator, r::sHadamardYZ)
4646
return l
4747
end
4848

49-
# function apply_right!(l::CliffordOperator, r::sPhase)
50-
# return l
51-
# end
49+
function apply_right!(l::CliffordOperator, r::sPhase)
50+
l[r.q] = mul_right_log_i!(l[r.q], l[nqubits(l)+r.q])
51+
apply_right!(l, sZ(r.q))
52+
return l
53+
end
5254

53-
# function apply_right!(l::CliffordOperator, r::sInvPhase)
54-
# return l
55-
# end
55+
function apply_right!(l::CliffordOperator, r::sInvPhase)
56+
l[r.q] = mul_right_log_i!(l[r.q], l[nqubits(l)+r.q])
57+
return l
58+
end
5659

5760
function apply_right!(l::CliffordOperator, r::sX)
5861
phases(tab(l))[nqubits(l)+r.q] ⊻= 0x02
@@ -104,13 +107,18 @@ function apply_right!(l::CliffordOperator, r::sInvSQRTZ)
104107
return l
105108
end
106109

107-
# function apply_right!(l::CliffordOperator, r::sCXYZ)
108-
# return l
109-
# end
110+
function apply_right!(l::CliffordOperator, r::sCXYZ)
111+
rowswap!(tab(l), r.q, nqubits(l)+r.q)
112+
l[r.q] = mul_right_log_i!(l[r.q], l[nqubits(l)+r.q])
113+
return l
114+
end
110115

111-
# function apply_right!(l::CliffordOperator, r::sCZYX)
112-
# return l
113-
# end
116+
function apply_right!(l::CliffordOperator, r::sCZYX)
117+
rowswap!(tab(l), r.q, nqubits(l)+r.q)
118+
l[nqubits(l)+r.q] = mul_right_log_i!(l[nqubits(l)+r.q], l[r.q])
119+
apply_right!(l, sX(r.q))
120+
return l
121+
end
114122

115123
function apply_right!(l::CliffordOperator, ::sId1)
116124
return l
@@ -128,6 +136,7 @@ function apply_right!(l::CliffordOperator, r::sSWAP)
128136
end
129137

130138
# function apply_right!(l::CliffordOperator, r::sSWAPCX)
139+
# rowswap!(tab(l), r.q1, r.q2)
131140
# return l
132141
# end
133142

test/test_apply_right.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
@test isequal(apply_right!(copy(l), sHadamard(q1)), apply_right_slow!(l, sHadamard(q1)))
4848
@test isequal(apply_right!(copy(l), sHadamardXY(q1)), apply_right_slow!(l, sHadamardXY(q1)))
4949
@test isequal(apply_right!(copy(l), sHadamardYZ(q1)), apply_right_slow!(l, sHadamardYZ(q1)))
50-
# @test isequal(apply_right!(copy(l), sPhase(q1)), apply_right_slow!(l, sPhase(q1)))
51-
# @test isequal(apply_right!(copy(l), sInvPhase(q1)), apply_right_slow!(l, sInvPhase(q1)))
50+
@test isequal(apply_right!(copy(l), sPhase(q1)), apply_right_slow!(l, sPhase(q1)))
51+
@test isequal(apply_right!(copy(l), sInvPhase(q1)), apply_right_slow!(l, sInvPhase(q1)))
5252
@test isequal(apply_right!(copy(l), sX(q1)), apply_right_slow!(l, sX(q1)))
5353
@test isequal(apply_right!(copy(l), sY(q1)), apply_right_slow!(l, sY(q1)))
5454
@test isequal(apply_right!(copy(l), sZ(q1)), apply_right_slow!(l, sZ(q1)))
@@ -58,8 +58,8 @@
5858
@test isequal(apply_right!(copy(l), sInvSQRTY(q1)), apply_right_slow!(l, sInvSQRTY(q1)))
5959
# @test isequal(apply_right!(copy(l), sSQRTZ(q1)), apply_right_slow!(l, sSQRTZ(q1)))
6060
# @test isequal(apply_right!(copy(l), sInvSQRTZ(q1)), apply_right_slow!(l, sInvSQRTZ(q1)))
61-
# @test isequal(apply_right!(copy(l), sCXYZ(q1)), apply_right_slow!(l, sCXYZ(q1)))
62-
# @test isequal(apply_right!(copy(l), sCZYX(q1)), apply_right_slow!(l, sCZYX(q1)))
61+
@test isequal(apply_right!(copy(l), sCXYZ(q1)), apply_right_slow!(l, sCXYZ(q1)))
62+
@test isequal(apply_right!(copy(l), sCZYX(q1)), apply_right_slow!(l, sCZYX(q1)))
6363
@test isequal(apply_right!(copy(l), sId1(q1)), apply_right_slow!(l, sId1(q1)))
6464
end
6565
end

test/test_inv.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
stabilizers = [S" I", S" X", S" Y", S" Z",
66
S"-I", S"-X", S"-Y", S"-Z",]
77
for gate in subtypes(AbstractSingleQubitOperator)
8-
gate == SingleQubitOperator && continue
8+
gate [SingleQubitOperator, sSQRTZ, sInvSQRTZ] && continue
99
for stab in stabilizers
1010
@test apply_inv!(stab, gate(1)) == apply!(stab, inv(CliffordOperator(gate(1), 1)))
1111
end

0 commit comments

Comments
 (0)