I have the following installation:
QuTiP Version: 4.0.2
Numpy Version: 1.12.0
Scipy Version: 0.18.1
Cython Version: 0.25.2
Matplotlib Version: 1.5.1
Python Version: 2.7.12
Number of CPUs: 2
I'm generating a csr_matrix but the QO formed from it complains
File "/home/cqt/PycharmProjects/QFI/ramsey.py", line 93, in bsb_flop
Wbsb.data = tr
File "/home/cqt/.local/lib/python2.7/site-packages/qutip/qobj.py", line 328, in set_data
raise TypeError('Qobj data must be in fast_csr format.')
TypeError: Qobj data must be in fast_csr format.
How do I convert from csr_matrix to fast_csr format?
part of the relevant code is :
def bsb_flop(rho0, W, eta, delta, theta, phi, c_op_list = [], return_op_list = []):
''' Return values of atom and motion populations during blue sideband Rabi flop
for rotation angles theta. Calls numerical solution of master equation for the
anti Jaynes-Cummings Hamiltonian.
@ var rho0: initial density matrix
@ var W: bare Rabi frequency
@ var delta: detuning between atom and motion
@ var theta: list of Rabi rotation angles (i.e. theta, or g*time)
@ var phi: phase of the input laser pulse
@ var c_op_list: list of collapse operators for the master equation treatment
@ var return_op_list: list of population operators the values of which will be returned
returns: time, populations of motional mode and atom
'''
N = shape(rho0.data)[0]/2 # assume N Fock states and two atom states
a = tensor(destroy(N), qeye(2))
sm = tensor( qeye(N), destroy(2))
Wbsb = destroy(N).dag()
# print csr_matrix(destroy(N).dag().data.dot(np.diag( rabi_coupling(N,1,eta) / np.sqrt(np.linspace(1,N,N)) ) ),dtype=complex)
tr = csr_matrix(destroy(N).dag().data.dot(np.diag( rabi_coupling(N,1,eta) / np.sqrt(np.linspace(1,N,N)) ) ))
print type(tr.indices[6])
Wbsb.data = fast_csr_matrix(tr)
# Wbsb.data = csr_matrix( destroy(N).dag().data.dot( np.diag( rabi_coupling(N,1,eta) / np.sqrt(np.linspace(1,N,N)))))
Absb = tensor(Wbsb.dag(), qeye(2))