QisKit:Statevector 上的差异/可视化上的无差异
QisKit: Difference on Statevector / No Difference on Vizualization
为什么状态向量有差异,但可视化没有差异?
是否有任何其他可视化来显示差异?
qiskit: 0.23.3
python: 3.8
circuit-1 + statevector:
q_0:
[1.+0.j 0.+0.j] ==> +1
circuit-2 + statevector
┌───┐┌───┐┌───┐┌───┐┌───┐
q_0: ┤ X ├┤ H ├┤ X ├┤ H ├┤ X ├
└───┘└───┘└───┘└───┘└───┘
[-1.+0.j -0.-0.j] ==> -1
代码示例
import numpy as np
from qiskit import *
import qiskit.tools.visualization as vis
import matplotlib. pyplot as plt
from qiskit import Aer
circ = QuantumCircuit(1)
circ.x(0)
circ.h(0)
circ.x(0)
circ.h(0)
circ.x(0)
backend = Aer.get_backend('statevector_simulator')
result = execute(circ, backend).result()
statevector = result.get_statevector()
vis.plot_bloch_multivector(statevector)
vis.plot_state_city(statevector)
vis.plot_state_qsphere(statevector)
vis.plot_state_paulivec(statevector)
circ.draw(output='mpl')
print(np.around(statevector,5))
plt.show()
两个状态向量的可视化是相等的!!
这对我来说似乎是一个错误(我报告了 here)
无论如何,我建议您 Kaleidoscope 将状态可视化。它有交互式图表。这是您的示例(为简洁而重构):
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
from kaleidoscope import qsphere
circ = QuantumCircuit(1)
circ.x(0)
circ.h(0)
circ.x(0)
circ.h(0)
circ.x(0)
state = Statevector.from_instruction(circ)
qsphere(state)
与另一个例子比较颜色:
circ = QuantumCircuit(1)
state = Statevector.from_instruction(circ)
qsphere(state)
颜色的不同就是相位。第一种情况是π.
为什么状态向量有差异,但可视化没有差异?
是否有任何其他可视化来显示差异?
qiskit: 0.23.3
python: 3.8
circuit-1 + statevector:
q_0:
[1.+0.j 0.+0.j] ==> +1
circuit-2 + statevector
┌───┐┌───┐┌───┐┌───┐┌───┐
q_0: ┤ X ├┤ H ├┤ X ├┤ H ├┤ X ├
└───┘└───┘└───┘└───┘└───┘
[-1.+0.j -0.-0.j] ==> -1
代码示例
import numpy as np
from qiskit import *
import qiskit.tools.visualization as vis
import matplotlib. pyplot as plt
from qiskit import Aer
circ = QuantumCircuit(1)
circ.x(0)
circ.h(0)
circ.x(0)
circ.h(0)
circ.x(0)
backend = Aer.get_backend('statevector_simulator')
result = execute(circ, backend).result()
statevector = result.get_statevector()
vis.plot_bloch_multivector(statevector)
vis.plot_state_city(statevector)
vis.plot_state_qsphere(statevector)
vis.plot_state_paulivec(statevector)
circ.draw(output='mpl')
print(np.around(statevector,5))
plt.show()
两个状态向量的可视化是相等的!!
这对我来说似乎是一个错误(我报告了 here)
无论如何,我建议您 Kaleidoscope 将状态可视化。它有交互式图表。这是您的示例(为简洁而重构):
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
from kaleidoscope import qsphere
circ = QuantumCircuit(1)
circ.x(0)
circ.h(0)
circ.x(0)
circ.h(0)
circ.x(0)
state = Statevector.from_instruction(circ)
qsphere(state)
与另一个例子比较颜色:
circ = QuantumCircuit(1)
state = Statevector.from_instruction(circ)
qsphere(state)
颜色的不同就是相位。第一种情况是π.