Skip to content

Commit ef2664e

Browse files
committed
symbolic prepends
1 parent 3f1446a commit ef2664e

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

src/backtrajectory.jl

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ function prepend_inv! end
3434

3535

3636
# FAST versions of prepend! and prepend_inv! for CliffordOperator - TODO
37-
prepend!(l::CliffordOperator, r; phases) = prepend!(l, CliffordOperator(r, nqubits(l)); phases=phases)
37+
function prepend!(l::CliffordOperator, r; phases)
38+
@warn "Slow prepend! operation"
39+
prepend!(l, CliffordOperator(r, nqubits(l)); phases=phases)
40+
end
3841

3942
function prepend!(l::CliffordOperator, r::CliffordOperator; phases=false)
4043
nqubits(l)==nqubits(r) || throw(DimensionMismatch("The tableau and the Clifford operator need to act on the same number of qubits. Consider specifying an array of indices as a third argument to the `apply!` function to avoid this error."))
@@ -71,14 +74,43 @@ end
7174
new_lrow
7275
end
7376

77+
78+
function prepend_inv!(l::CliffordOperator, r; phases=false)
79+
@warn "Slow prepend_inv! operation"
80+
prepend!(l, inv(CliffordOperator(r, nqubits(l))); phases=phases)
81+
end
7482
function prepend_inv!(l::CliffordOperator, r::CliffordOperator; phases=false)
7583
prepend!(l, inv(r); phases=phases)
7684
end
7785

78-
# SLOW
79-
function prepend_inv!(l::CliffordOperator, r; phases=false)
80-
prepend!(l, inv(CliffordOperator(r, nqubits(l))); phases=phases)
86+
# Symbolic
87+
function prepend!(l::CliffordOperator, r::sX; phases=false)
88+
tab(l).phases[nqubits(l)+r.q] ⊻= 0x02
89+
return l
8190
end
91+
function prepend!(l::CliffordOperator, r::sY; phases=false)
92+
tab(l).phases[r.q] ⊻= 0x02
93+
tab(l).phases[nqubits(l)+r.q] ⊻= 0x02
94+
return l
95+
end
96+
function prepend!(l::CliffordOperator, r::sZ; phases=false)
97+
tab(l).phases[r.q] ⊻= 0x02
98+
return l
99+
end
100+
101+
function prepend_inv!(l::CliffordOperator, r::sX; phases=false)
102+
tab(l).phases[nqubits(l)+r.q] ⊻= 0x02
103+
return l
104+
end
105+
function prepend_inv!(l::CliffordOperator, r::sY; phases=false)
106+
error("Not implemented: prepend_inv!(l, r::sY)")
107+
return l
108+
end
109+
function prepend_inv!(l::CliffordOperator, r::sZ; phases=false)
110+
tab(l).phases[r.q] ⊻= 0x02
111+
return l
112+
end
113+
82114

83115
"""
84116
Simulates measurement results of a Clifford circuit acting on an `n`-qubit |0⟩^⊗n state using the stabilizer tableau backtracking method,

0 commit comments

Comments
 (0)