In [1]:
from qutip import *
In [2]:
from qutip.cyQ.spmatfuncs import cy_expect
In [3]:
N = 50
In [4]:
op = rand_herm(N)
ket = rand_ket(N)
rho = ket2dm(ket)
ket_data = ket.full()
op_data = op.data
In [5]:
sop = spre(op)
sop_data = sop.data
In [6]:
rho_vec = operator_to_vector(rho)
rho_vec_data = rho_vec.full()
In [7]:
expect(op, ket)
Out[7]:
In [8]:
expect(op, rho)
Out[8]:
In [9]:
cy_expect(op_data.data, op_data.indices, op_data.indptr, ket_data, 1)
Out[9]:
In [10]:
expect_psi(op_data, ket_data, 1)
Out[10]:
In [11]:
expect_rho_vec(sop_data, rho_vec_data, 1)
Out[11]:
In [12]:
%%timeit
expect(op, ket)
In [13]:
%%timeit
cy_expect(op_data.data, op_data.indices, op_data.indptr, ket_data, 1)
In [14]:
%%timeit
expect_psi(op_data, ket_data, 1)
In [15]:
%%timeit
expect(op, rho)
In [16]:
%%timeit
expect_rho_vec(sop_data, rho_vec_data)
In [17]:
from qutip.ipynbtools import version_table
version_table()
Out[17]:
In [ ]: