MCMT
class qiskit.circuit.library.MCMT(gate, num_ctrl_qubits, num_target_qubits)
Bases: QuantumCircuit
The multi-controlled multi-target gate, for an arbitrary singly controlled target gate.
For example, the H gate controlled on 3 qubits and acting on 2 target qubit is represented as:
───■────
│
───■────
│
───■────
┌──┴───┐
┤0 ├
│ 2-H │
┤1 ├
└──────┘This default implementations requires no ancilla qubits, by broadcasting the target gate to the number of target qubits and using Qiskit’s generic control routine to control the broadcasted target on the control qubits. If ancilla qubits are available, a more efficient variant using the so-called V-chain decomposition can be used. This is implemented in MCMTVChain.
Create a new multi-control multi-target gate.
The class qiskit.circuit.library.generalized_gates.mcmt.MCMT is deprecated as of Qiskit 1.4. It will be removed no earlier than 3 months after the release date. Use MCMTGate instead.
Parameters
- gate (Gate | Callable[[QuantumCircuit, circuit.Qubit, circuit.Qubit], circuit.Instruction]) – The gate to be applied controlled on the control qubits and applied to the target qubits. Can be either a Gate or a circuit method. If it is a callable, it will be casted to a Gate.
- num_ctrl_qubits (int) – The number of control qubits.
- num_target_qubits (int) – The number of target qubits.
Raises
- AttributeError – If the gate cannot be casted to a controlled gate.
- AttributeError – If the number of controls or targets is 0.
Attributes
num_ancilla_qubits
Return the number of ancillas.
name
Type: str
A human-readable name for the circuit.
Example
from qiskit import QuantumCircuit
qc = QuantumCircuit(2, 2, name="my_circuit")
print(qc.name)my_circuitMethods
control
control(num_ctrl_qubits=1, label=None, ctrl_state=None, annotated=False)
Return the controlled version of the MCMT circuit.