|
19 | 19 | Synthesis of Quantum Logic Circuits. Tech. rep. 2006,
|
20 | 20 | https://arxiv.org/abs/quant-ph/0406176
|
21 | 21 | """
|
22 |
| -from typing import List, Callable, TYPE_CHECKING |
| 22 | +from typing import Callable, Iterable, List, TYPE_CHECKING |
23 | 23 |
|
24 | 24 | from scipy.linalg import cossin
|
25 | 25 |
|
|
38 | 38 |
|
39 | 39 | if TYPE_CHECKING:
|
40 | 40 | import cirq
|
41 |
| - from cirq.ops import op_tree |
42 | 41 |
|
43 | 42 |
|
44 | 43 | def quantum_shannon_decomposition(
|
45 | 44 | qubits: 'List[cirq.Qid]', u: np.ndarray, atol: float = 1e-8
|
46 |
| -) -> 'op_tree.OpTree': |
| 45 | +) -> Iterable['cirq.Operation']: |
47 | 46 | """Decomposes n-qubit unitary 1-q, 2-q and GlobalPhase gates, preserving global phase.
|
48 | 47 |
|
49 | 48 | The gates used are CX/YPow/ZPow/CNOT/GlobalPhase/CZ/PhasedXZGate/PhasedXPowGate.
|
@@ -141,7 +140,7 @@ def quantum_shannon_decomposition(
|
141 | 140 | yield from _msb_demuxer(qubits, u1, u2)
|
142 | 141 |
|
143 | 142 |
|
144 |
| -def _single_qubit_decomposition(qubit: 'cirq.Qid', u: np.ndarray) -> 'op_tree.OpTree': |
| 143 | +def _single_qubit_decomposition(qubit: 'cirq.Qid', u: np.ndarray) -> Iterable['cirq.Operation']: |
145 | 144 | """Decomposes single-qubit gate, and returns list of operations, keeping phase invariant.
|
146 | 145 |
|
147 | 146 | Args:
|
@@ -186,7 +185,7 @@ def _single_qubit_decomposition(qubit: 'cirq.Qid', u: np.ndarray) -> 'op_tree.Op
|
186 | 185 |
|
187 | 186 | def _msb_demuxer(
|
188 | 187 | demux_qubits: 'List[cirq.Qid]', u1: np.ndarray, u2: np.ndarray
|
189 |
| -) -> 'op_tree.OpTree': |
| 188 | +) -> Iterable['cirq.Operation']: |
190 | 189 | """Demultiplexes a unitary matrix that is multiplexed in its most-significant-qubit.
|
191 | 190 |
|
192 | 191 | Decomposition structure:
|
@@ -249,7 +248,7 @@ def _nth_gray(n: int) -> int:
|
249 | 248 |
|
250 | 249 | def _multiplexed_cossin(
|
251 | 250 | cossin_qubits: 'List[cirq.Qid]', angles: List[float], rot_func: Callable = ops.ry
|
252 |
| -) -> 'op_tree.OpTree': |
| 251 | +) -> Iterable['cirq.Operation']: |
253 | 252 | """Performs a multiplexed rotation over all qubits in this unitary matrix,
|
254 | 253 |
|
255 | 254 | Uses ry and rz multiplexing for quantum shannon decomposition
|
|
0 commit comments