如何在Python的QuTiP中获取量子对象的指数

2024-09-26 17:49:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我想取量子对象rho1(基本上是一个矩阵/数组)的所有元素,计算这些元素的指数,得到一个矩阵/数组rho2。我该怎么做?在

显然,来自numpyexp不起作用(我得到一个错误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

Tags: importnumpy元素asnpbasis矩阵数组
2条回答

这是有效的:

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

要对qobj执行elementwise exp,可以对底层稀疏数据进行操作。在

rho2=rho1 rho2。数据。数据= np.exp.公司(rho1。数据。数据)在

相关问题 更多 >

    热门问题