Commit 6b6a7ff
authored
Fix global phase computation in matrix gate decomposition (#7482)
Fixes #7473
Old code with `cirq.unitary(circuit)` performs the unitary assuming the
qubit order is ascending based on the qubit id. (The identity operator
in that code helped when some qubits were factored out during
decomposition, but didn't help with ordering). Changed to
`circuit.unitary(qubits, qubits)` to make the qubit order explicit. The
first one defines the ordering to be the same as the decomposed
matrixgate, and the second makes sure that all qubits are retained even
if the decomposition factored some out)1 parent 3031b1f commit 6b6a7ff
2 files changed
+16
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
| 173 | + | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
0 commit comments