qml.ops.multi_qubit_decomposition

multi_qubit_decomposition(U, wires)[source]

Decompose a multi-qubit unitary \(U\) in terms of elementary operations.

The n-qubit unitary \(U\), with \(n > 1\), is decomposed into four (\(n-1\))-qubit unitaries (QubitUnitary) and three multiplexers (SelectPauliRot) using the cosine-sine decomposition. This implementation is based on arXiv:quant-ph/0504100.

Parameters:
  • U (tensor) – A \(2^n \times 2^n\) unitary matrix with \(n > 1\).

  • wires (Union[Wires, Sequence[int] or int]) – The wires on which to apply the operation.

Returns:

A list of operations that represent the decomposition of the matrix U.

Return type:

list[Operation]

Example

>>> matrix_target = qml.matrix(qml.QFT([0,1,2]))
>>> ops = qml.ops.multi_qubit_decomposition(matrix_target, [0,1,2])
>>> matrix_decomposition = qml.matrix(qml.prod(*ops[::-1]), wire_order = [0,1,2])
>>> print([op.name for op in ops])
['QubitUnitary', 'SelectPauliRot', 'QubitUnitary', 'SelectPauliRot', 'QubitUnitary', 'SelectPauliRot', 'QubitUnitary']
>>> print(np.allclose(matrix_decomposition, matrix_target))
True