Recover the decomposition of a single-qubit matrix \(U\) in terms of elementary operations.
Diagonal operations will be converted to a single
RZgate, while non-diagonal operations will be converted to a
Rotgate that implements the original operation up to a global phase in the form \(RZ(\omega) RY(\theta) RZ(\phi)\).
U (tensor) – A 2 x 2 unitary matrix.
wire (Union[Wires, Sequence[int] or int]) – The wire on which to apply the operation.
Rotgate on the specified wire that implements
Uup to a global phase, or an equivalent
- Return type
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 a
Rotgate that implements the same operation, up to a global phase:
>>> decomp = zyz_decomposition(U, 0) >>> decomp [Rot(-0.24209529417800013, 1.14938178234275, 1.7330581433950871, wires=)]