Skip to main contentIBM Quantum Documentation Mirror

MCXRecursive

class qiskit.circuit.library.MCXRecursive(num_ctrl_qubits=None, label=None, ctrl_state=None, *, _base_label=None)

GitHub

Bases: MCXGate

Implement the multi-controlled X gate using recursion.

Using a single clean ancilla qubit, the multi-controlled X gate is split into four sub-registers, each one of them uses the V-chain method.

The method is based on Lemma 9 of [2], first shown in Lemma 7.3 of [1].

References

  1. Barenco et al., 1995. https://arxiv.org/pdf/quant-ph/9503016.pdf
  2. Iten et al., 2015. https://arxiv.org/abs/1501.06911

Create new MCX gate.


Methods

Parameters

  • num_ctrl_qubits (Optional[int]) –
  • label (Optional[str]) –
  • ctrl_state (Optional[Union[str, int]]) –

get_num_ancilla_qubits

static get_num_ancilla_qubits(num_ctrl_qubits, mode='recursion')

GitHub

Get the number of required ancilla qubits.

Parameters

  • num_ctrl_qubits (int) –
  • mode (str) –

inverse

inverse(annotated=False)

GitHub

Invert this gate. The MCX is its own inverse.

Parameters

annotated (bool) – when set to True, this is typically used to return an AnnotatedOperation with an inverse modifier set instead of a concrete Gate. However, for this class this argument is ignored as this gate is self-inverse.

Returns

inverse gate (self-inverse).

Return type

MCXRecursive