質問する
404 次
1 に答える
1
The conversion depends on a couple arbitrary choices:
- Do you want |0⟩ at the top or the bottom?
- Do you want the coordinate system to be right-handed or left-handed?
Assuming you answer those with "at the bottom" and "right-handed", then this method will do it:
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
You switch to other choices by picking and choosing which outputs to negate.
Testing it out:
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 に答える