View on GitHub
Open this notebook in GitHub to run it yourself
Multi-Control-X
The multi-control-X applies X gate to one target qubit bit only if the logical AND of all control qubits is satisfied. The multi-control-X function incorporates numerous implementations for the multi-control-X gate, each with a different depth and number of auxiliary qubits. These implementations generically outperform the Gray-code, V-chain and recursive implementations of Ref. [1], as well as the relative-phase Toffoli implementation of Ref. [2]. Given a sufficient number of auxiliary qubits, some implementations allow for logarithmic depth and linear CX-count. The synthesis process selects the appropriate implementation depending on the defined constraints. Operator:control
Arguments:
ctrl: Union[QBit, QArray[QBit]]stmt_block: QCallable
control takes a qubit array of length one or more as ctrl, and applies the stmt_block operand if all qubits are in the 1 state
Example
The following example shows how to use thecontrol operator to implement a Multi-Control-X where a 7-qubit quantum variable serves as the control