---
title: MCXVChain (latest version)
description: API reference for qiskit.circuit.library.MCXVChain in the latest version of qiskit
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/qiskit.circuit.library.MCXVChain
---

# MCXVChain

*class* `qiskit.circuit.library.MCXVChain(num_ctrl_qubits=None, dirty_ancillas=False, label=None, ctrl_state=None, *, _base_label=None, relative_phase=False, action_only=False)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/circuit/library/standard_gates/x.py#L1195-L1325)

Bases: [`MCXGate`](/docs/api/qiskit/qiskit.circuit.library.MCXGate "qiskit.circuit.library.standard_gates.x.MCXGate")

Implement the multi-controlled X gate using a V-chain of CX gates.

**Parameters**

- **num\_ctrl\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int) *| None*) – Number of controls to add. Defaults to `1`.
- **dirty\_ancillas** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – when set to `True`, the method applies an optimized multicontrolled-X gate up to a relative phase using dirty ancillary qubits with the properties of lemmas 7 and 8 from arXiv:1501.06911, with at most 8\*k - 6 CNOT gates. For k within the range \{1, …, ceil(n/2)}. And for n representing the total number of qubits.
- **label** ([*str*](https://docs.python.org/3/library/stdtypes.html#str) *| None*) – Optional gate label. Defaults to `None`.
- **ctrl\_state** ([*int*](https://docs.python.org/3/library/functions.html#int)  *|*[*str*](https://docs.python.org/3/library/stdtypes.html#str) *| None*) – The control state of the gate, specified either as an integer or a bitstring (e.g. `"110"`). If `None`, defaults to the all-ones state `2**num_ctrl_qubits - 1`
- **relative\_phase** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – when set to `True`, the method applies the optimized multicontrolled-X gate up to a relative phase, in a way that, by lemma 7 of arXiv:1501.06911, the relative phases of the `action part` cancel out with the phases of the `reset part`.
- **action\_only** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – when set to `True`, the method applies only the action part of lemma 8 from arXiv:1501.06911.

## Methods

### get\_num\_ancilla\_qubits

*static* `get_num_ancilla_qubits(num_ctrl_qubits, mode='v-chain')`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/circuit/library/standard_gates/x.py#L1301-L1304)

Get the number of required ancilla qubits.

**Parameters**

- **num\_ctrl\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int))
- **mode** ([*str*](https://docs.python.org/3/library/stdtypes.html#str))

### inverse

`inverse(annotated=False)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/circuit/library/standard_gates/x.py#L1274-L1299)

Invert this gate. The MCX is its own inverse.

**Parameters**

**annotated** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – when set to `True`, this is typically used to return an [`AnnotatedOperation`](/docs/api/qiskit/qiskit.circuit.AnnotatedOperation "qiskit.circuit.AnnotatedOperation") with an inverse modifier set instead of a concrete [`Gate`](/docs/api/qiskit/qiskit.circuit.Gate "qiskit.circuit.Gate"). However, for this class this argument is ignored as this gate is self-inverse.

**Returns**

inverse gate (self-inverse).

**Return type**

[MCXVChain](#qiskit.circuit.library.MCXVChain "qiskit.circuit.library.MCXVChain")
