[英]on qutip is it possible to transform a state to vector?
If I build a state如果我建立一个国家
from qutip import Bloch,basis
state=(basis(2,0)+(0+1j)*basis(2,1)).unit()
can I trasform it in a bloch-sphere vector ?我可以在bloch-sphere 向量中转换它吗?
In this form:在这种形式中:
state -> vec=np.array
it's possible to convert a 2dvector in C(2) into a vector in R(3) living inside the bloch-sphere using this code:可以使用以下代码将 C(2) 中的 2dvector 转换为位于 bloch-sphere 内的 R(3) 中的向量:
from qutip.operators import sigmax, sigmay, sigmaz
def extract_vec(v):
v=[v]
vector=[]
for i in v:
vector.append([
expect(sigmax(),i),
expect(sigmay(),i),
expect(sigmaz(),i)
])
return(vector)
3d_vec=extract_vec(state)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.