我想获取量子对象rho1(基本上是一个矩阵/数组)的所有元素并计算元素的指数以获得矩阵/数组rho2。我该怎么做?
显然 numpy 中的 exp 不起作用(我收到错误 AttributeError: exp)。 qutip 函数不执行我的特定计算,它返回一个具有不同维度的数组。
import numpy as np
import qutip as qt
N = 2
M = 2
# angular momentum
Jp = qt.tensor(qt.qeye(M), qt.jmat(N/2.0, '+'))
Jm = qt.tensor(qt.qeye(M), qt.jmat(N/2.0, '-'))
# make initial state
rho1 = qt.tensor(qt.basis(M,0), qt.basis(N+1,N))
print rho1
# make another state
Jx = (Jp + Jm) / 2.0 # angular momentum
# x = np.exp(1j*np.pi*Jx) * rho1
x = (1j*np.pi*Jx).expm() * rho1
rho2 = qt.tensor(qt.basis(M,0), x)
print rho2
请您参考如下方法:
这个有效:
import numpy as np
import qutip as qt
N = 2
M = 2
Jp = qt.tensor(qt.qeye(M), qt.jmat(J, '+')) # J+
Jm = qt.tensor(qt.qeye(M), qt.jmat(J, '-')) # J-
# angular momentum
Jx = (Jp + Jm) / 2.0
# initial state
rho0 = qt.tensor(qt.basis(M,0), qt.basis(N+1,N))
R = (1j*0.5*np.pi*Jx).expm() # rotation transform
rho = R * rho0
