问问题
404 次
1 回答
1
转换取决于几个任意选择:
- 你想要 |0⟩ 在顶部还是底部?
- 您希望坐标系是右手还是左手?
假设你用“在底部”和“右撇子”来回答那些问题,那么这个方法就可以做到:
def toBloch(matrix):
[[a, b], [c, d]] = matrix
x = complex(c + b).real
y = complex(c - b).imag
z = complex(d - a).real
return x, y, z
您可以通过选择要否定的输出来切换到其他选择。
测试一下:
print(toBloch([[1, 0],
[0, 0]])) #Off, Z=-1
# (0.0, 0.0, -1.0)
print(toBloch([[0, 0],
[0, 1]])) #On, Z=+1
# (0.0, 0.0, 1.0)
print(toBloch([[0.5, 0.5],
[0.5, 0.5]])) #On+Off, X=-1
# (-1.0, 0.0, 0.0)
print(toBloch([[0.5, 0.5j],
[-0.5j, 0.5]])) #On+iOff, Y=-1
# (0.0, -1.0, 0.0)
print(toBloch([[0.5, 0.0],
[0.0, 0.5]])) #maximally mixed state, X=Y=Z=0
# (0.0, 0.0, 0.0)
于 2016-10-02T20:46:55.940 回答