python ket.draw()未显示|00>:奇斯基特

jtjikinw  于 2023-01-19  发布在  Python
关注(0)|答案(1)|浏览(92)

ket.draw()必须给予|00>作为结果,但我得到:

Statevector([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
               dims=(2, 2))

我可以改变什么来得到想要的结果?
这是我的代码:

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

qc = QuantumCircuit(2)

# This calculates what the state vector of our qubits would be
# after passing through the circuit 'qc'
ket = Statevector(qc)

# The code below writes down the state vector.
# Since it's the last line in the cell, the cell will display it as output
ket.draw()
whlutmcx

whlutmcx1#

您可以将关键字参数output='latex'传递给.draw方法。

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

qc = QuantumCircuit(2)

# This calculates what the state vector of our qubits would be
# after passing through the circuit 'qc'
ket = Statevector(qc)

# The code below writes down the state vector.
# Since it's the last line in the cell, the cell will display it as output
ket.draw(output='latex')

相关问题