This message pops up when I run an mcrx gate
The mcrx gate needs a single qubit as target.
Here is a part of code I run:
QC.mcrx(np.pi,[0,1,2],3)
QC.draw('mpl')
This message pops up when I run an mcrx gate
The mcrx gate needs a single qubit as target.
Here is a part of code I run:
QC.mcrx(np.pi,[0,1,2],3)
QC.draw('mpl')
Here is a way to implement multi-controlled RX gate if you interested:
from qiskit import QuantumCircuit,QuantumRegister
from qiskit.circuit.library.standard_gates import RXGate
from qiskit.circuit import Parameter
import matplotlib.pyplot as plt
qr=QuantumRegister(4)
circ=QuantumCircuit(qr)
a=Parameter('a') # You can replace a with pi here
CCCRX=RXGate(a).control(3)
circ.append(CCCRX,qr)
print(circ)
Which output:
q0: ────■────
│
q1: ────■────
│
q2: ────■────
┌───┴───┐
q3: ┤ RX(a) ├
└───────┘
You can decompose this circuit to looks what is being implement underneath by executing the line of code: circ.decompose().draw()
which will output:
If you absolutely want to use mcrx
method then this should do it:
from qiskit.circuit.library.standard_gates import mcrx
import numpy as np
qr= QuantumRegister(4)
circ=QuantumCircuit(qr)
circ.mcrx(np.pi,[ qr[0], qr[1], qr[2] ],qr[3])
note that if I decompose this circuit (like we did earlier), I will get the exact same circuit as the decomposed circuit on top (by replacing 'a' with pi
to the top circuit):