Decomposes n-qubit unitary into CX/YPow/ZPow/CNOT gates, preserving global phase.

The algorithm is described in Shende et al.: Synthesis of Quantum Logic Circuits. Tech. rep. 2006,

qubits List of qubits in order of significance
u Numpy array for unitary matrix representing gate to be decomposed

(Base Case)

  1. _single_qubit_decomposition OR (Recursive Case)
  2. _msb_demuxer
  3. _multiplexed_cossin
  4. _msb_demuxer

A single 2-qubit or 1-qubit operations from OP TREE composed from the set { CNOT, rz, ry, ZPowGate }

ValueError If the u matrix is non-unitary
ValueError If the u matrix is not of shape (2^n,2^n)