qml.transforms.zyz_decomposition¶
-
zyz_decomposition
(U, wire)[source]¶ Recover the decomposition of a single-qubit matrix \(U\) in terms of elementary operations.
Diagonal operations can be converted to a single
RZ
gate, while non-diagonal operations will be converted to aRot
gate that implements the original operation up to a global phase in the form \(RZ(\omega) RY(\theta) RZ(\phi)\).Warning
When used with
jax.jit
, all unitaries will be converted toRot
gates, including those that are diagonal.- Parameters
- Returns
A
Rot
gate on the specified wire that implementsU
up to a global phase, or an equivalentRZ
gate ifU
is diagonal.- Return type
list[qml.Operation]
Example
Suppose we would like to apply the following unitary operation:
U = np.array([ [-0.28829348-0.78829734j, 0.30364367+0.45085995j], [ 0.53396245-0.10177564j, 0.76279558-0.35024096j] ])
For PennyLane devices that cannot natively implement
QubitUnitary
, we can instead recover aRot
gate that implements the same operation, up to a global phase:>>> decomp = zyz_decomposition(U, 0) >>> decomp [Rot(-0.24209529417800013, 1.14938178234275, 1.7330581433950871, wires=[0])]