我想取量子对象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
这是有效的:
要对qobj执行elementwise exp,可以对底层稀疏数据进行操作。在
rho2=rho1 rho2。数据。数据= np.exp.公司(rho1。数据。数据)在
相关问题 更多 >
编程相关推荐