|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | import math |
16 | | -from typing import cast, Mapping, Optional |
| 16 | +from typing import cast, Mapping, Optional, Union |
17 | 17 |
|
18 | 18 | import cirq |
19 | 19 | import numpy as np |
@@ -103,27 +103,28 @@ def _matsumoto_amano_sequence(matrix: _su2_ct.SU2CliffordT) -> tuple[str, ...]: |
103 | 103 | if np.all(parity[:, i] == 0): |
104 | 104 | parity[:, [i, 2]] = parity[:, [2, i]] |
105 | 105 | break |
106 | | - gates : tuple[str, ...] = () |
| 106 | + gates: tuple[str, ...] = () |
| 107 | + new: Union[_su2_ct.SU2CliffordT, None] |
107 | 108 | if np.array_equal(parity, np.array([[1, 1, 0], [1, 1, 0], [0, 0, 0]])): |
108 | 109 | # Leftmost syllabe is T |
109 | | - new = _su2_ct.TSqrt2.adjoint() @ matrix |
| 110 | + new = _su2_ct.Tz.adjoint() @ matrix |
110 | 111 | gates = ('T',) |
111 | 112 | elif np.array_equal(parity, np.array([[0, 0, 0], [1, 1, 0], [1, 1, 0]])): |
112 | 113 | # Leftmost syllabe is HT |
113 | 114 | new = _su2_ct.HSqrt2.adjoint() @ matrix |
114 | | - new = _su2_ct.TSqrt2.adjoint() @ new |
| 115 | + new = _su2_ct.Tz.adjoint() @ new |
115 | 116 | gates = ('T', 'H') |
116 | 117 | elif np.array_equal(parity, np.array([[1, 1, 0], [0, 0, 0], [1, 1, 0]])): |
117 | 118 | # Leftmost syllabe is SHT |
118 | 119 | new = _su2_ct.SSqrt2.adjoint() @ matrix |
119 | 120 | new = _su2_ct.HSqrt2.adjoint() @ new |
120 | | - new = _su2_ct.TSqrt2.adjoint() @ new |
| 121 | + new = _su2_ct.Tz.adjoint() @ new |
121 | 122 | gates = ('T', 'H', 'S') |
122 | 123 | else: |
123 | 124 | raise ValueError(f'Unexpected parity matrix:\n{parity}') |
124 | 125 | new = new.scale_down() |
125 | 126 | if new is None or not new.is_valid(): |
126 | | - raise ValueError(f'Invalid SU2CliffordT matrix\n{new.matrix}') |
| 127 | + raise ValueError('Invalid SU2CliffordT matrix') |
127 | 128 | seq = _matsumoto_amano_sequence(new) |
128 | 129 | return seq + gates |
129 | 130 |
|
|
0 commit comments