qml.transforms.xyx_decomposition¶
-
xyx_decomposition
(U, wire, return_global_phase=False)[source]¶ Compute the decomposition of a single-qubit matrix \(U\) in terms of elementary operations, as a product of X and Y rotations in the form \(e^{i\gamma} RX(\phi) RY(\theta) RX(\lambda)\).
- Parameters
U (array[complex]) – A 2 x 2 unitary matrix.
wire (Union[Wires, Sequence[int] or int]) – The wire on which to apply the operation.
return_global_phase (bool) – Whether to return the global phase as a qml.s_prod between exp(1j)*gamma and qml.Identity as the last element of the returned list of operations.
- Returns
Returns a list of of gates, an
RX
, anRY
and anotherRX
gate, which when applied in the order of appearance in the list is equivalent to the unitary \(U\) up to global phase. If return_global_phase=True, the global phase is returned as the last element of the list.- Return type
list[Operation]
Example
>>> U = np.array([[-0.28829348-0.78829734j, 0.30364367+0.45085995j], ... [ 0.53396245-0.10177564j, 0.76279558-0.35024096j]]) >>> decomp = xyx_decomposition(U, 0, return_global_phase=True) >>> decomp [RX(array(0.45246584), wires=[0]), RY(array(1.39749741), wires=[0]), RX(array(-1.72101925), wires=[0]), (0.38469215914523336-0.9230449299422961j)*(Identity(wires=[0]))]