In [2]:
from qiskit.circuit.library import QFT
In [3]:
from qiskit import *
In [4]:
from qiskit.visualization import *
In [5]:
backend = BasicAer.get_backend('statevector_simulator')
In [8]:
qc000 = QFT(3)
In [44]:
job000 = execute(qc000, backend).result()
In [10]:
result000 = job000.result()
In [12]:
plot_bloch_multivector(result000.get_statevector())
/home/al/.local/lib/python3.9/site-packages/qiskit/visualization/bloch.py:69: MatplotlibDeprecationWarning: 
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
  x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
Out[12]:
In [13]:
qc001 = QuantumCircuit(3)
In [14]:
qc001.x(0)
Out[14]:
<qiskit.circuit.instructionset.InstructionSet at 0x7fe90fcadb50>
In [16]:
qc001 = qc001 + QFT(3)
<ipython-input-16-d7cc1db18362>:1: DeprecationWarning: The QuantumCircuit.__add__() method is being deprecated.Use the compose() method which is more flexible w.r.t circuit register compatibility.
  qc001 = qc001 + QFT(3)
/home/al/.local/lib/python3.9/site-packages/qiskit/circuit/quantumcircuit.py:869: DeprecationWarning: The QuantumCircuit.combine() method is being deprecated. Use the compose() method which is more flexible w.r.t circuit register compatibility.
  return self.combine(rhs)
In [17]:
qc001.draw()
Out[17]:
     ┌───┐                                ┌───┐   
q_0: ┤ X ├──────────■─────────────■───────┤ H ├─X─
     └───┘          │       ┌───┐ │P(π/2) └───┘ │ 
q_1: ──────■────────┼───────┤ H ├─■─────────────┼─
     ┌───┐ │P(π/2)  │P(π/4) └───┘               │ 
q_2: ┤ H ├─■────────■───────────────────────────X─
     └───┘                                        
In [18]:
job001 = execute(qc001, backend)
In [20]:
result001 = job001.result()
In [21]:
plot_bloch_multivector(result001.get_statevector())
/home/al/.local/lib/python3.9/site-packages/qiskit/visualization/bloch.py:69: MatplotlibDeprecationWarning: 
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
  x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
Out[21]:
In [22]:
qc100 = QuantumCircuit(3)
In [23]:
qc100.x(2)
Out[23]:
<qiskit.circuit.instructionset.InstructionSet at 0x7fe90e1dbee0>
In [24]:
qc100 = qc100 + QFT(3)
In [27]:
job100 = execute(qc100, backend)
In [28]:
result100 = job100.result()
In [30]:
plot_bloch_multivector(result100.get_statevector())
/home/al/.local/lib/python3.9/site-packages/qiskit/visualization/bloch.py:69: MatplotlibDeprecationWarning: 
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
  x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
Out[30]:
In [31]:
qc010 = QuantumCircuit(3)
In [32]:
qc010.x(1)
Out[32]:
<qiskit.circuit.instructionset.InstructionSet at 0x7fe90dbf90d0>
In [33]:
qc010 = qc010 + QFT(3)
In [34]:
job010=execute(qc010,backend)
In [35]:
result010 = job010.result()
In [36]:
plot_bloch_multivector(result010.get_statevector())
/home/al/.local/lib/python3.9/site-packages/qiskit/visualization/bloch.py:69: MatplotlibDeprecationWarning: 
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
  x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
Out[36]:
In [37]:
qc011 = QuantumCircuit(3)
In [38]:
qc011.x(0)
Out[38]:
<qiskit.circuit.instructionset.InstructionSet at 0x7fe90d965f10>
In [39]:
qc011.x(1)
Out[39]:
<qiskit.circuit.instructionset.InstructionSet at 0x7fe90da63100>
In [40]:
qc011 = qc011 + QFT(3)
In [41]:
job011=execute(qc011,backend)
In [42]:
result011 = job011.result()
In [43]:
plot_bloch_multivector(result011.get_statevector())
/home/al/.local/lib/python3.9/site-packages/qiskit/visualization/bloch.py:69: MatplotlibDeprecationWarning: 
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
  x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
Out[43]:
In [19]:
qcsp = QuantumCircuit(3)
In [20]:
qcsp.h(0)
Out[20]:
<qiskit.circuit.instructionset.InstructionSet at 0x7f565c182bb0>
In [21]:
qcsp.x(1)
Out[21]:
<qiskit.circuit.instructionset.InstructionSet at 0x7f56b0593460>
In [22]:
qcsp = qcsp +QFT(3)
In [23]:
qcsp.draw()
Out[23]:
     ┌───┐                                ┌───┐   
q_0: ┤ H ├──────────■─────────────■───────┤ H ├─X─
     ├───┤          │       ┌───┐ │P(π/2) └───┘ │ 
q_1: ┤ X ├─■────────┼───────┤ H ├─■─────────────┼─
     ├───┤ │P(π/2)  │P(π/4) └───┘               │ 
q_2: ┤ H ├─■────────■───────────────────────────X─
     └───┘                                        
In [16]:
job_011_010sp=execute(qcsp,backend).result()
In [24]:
plot_bloch_multivector(job_011_010sp.get_statevector(decimals=3))
/home/al/.local/lib/python3.9/site-packages/qiskit/visualization/bloch.py:69: MatplotlibDeprecationWarning: 
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
  x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
Out[24]:
In [25]:
qcsp2 = QuantumCircuit(3)
In [26]:
qcsp2.h(0)
Out[26]:
<qiskit.circuit.instructionset.InstructionSet at 0x7f5659dc0160>
In [27]:
qcsp2 = qcsp2 + QFT(3)
In [28]:
qcsp2.draw()
Out[28]:
     ┌───┐                                ┌───┐   
q_0: ┤ H ├──────────■─────────────■───────┤ H ├─X─
     └───┘          │       ┌───┐ │P(π/2) └───┘ │ 
q_1: ──────■────────┼───────┤ H ├─■─────────────┼─
     ┌───┐ │P(π/2)  │P(π/4) └───┘               │ 
q_2: ┤ H ├─■────────■───────────────────────────X─
     └───┘                                        
In [29]:
job001_000=execute(qcsp2,backend).result()
In [30]:
plot_bloch_multivector(job001_000.get_statevector())
/home/al/.local/lib/python3.9/site-packages/qiskit/visualization/bloch.py:69: MatplotlibDeprecationWarning: 
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
  x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
Out[30]:
In [ ]: