2016-10-02 216 views

回答

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)