I'm trying to use the following function of QuTip library:
coherent_dm(N=10, alpha = c, offset=0, method='operator')
It's output is a matrix and it's input is a complex number "c", however I want to get the matrices for a list of multiple "c" numbers, but if I define "c" as:
t = np.linspace(0,2*np.pi,100)
c = 2*np.exp(-t*1j) + 0.1*10*(1 - np.exp(-t*1j))
And run the code it gives me "dimension mismatch" error. In this case I tried to run a list of a 100 complex numbers as input "c" expecting an output of a 100 matrices. Any ideas on how to solve this problem would be appreciated.
coherent_dm
returns a qutip.Qobj
instance. This is a specialized object that fulfills the __array__
interface, but is not actually a numpy array. Internally, it appears to contain a sparse matrix. That means that you can not readily make coherent_dm
return more than one matrix at a time, or even concatenate the results of multiple calls into a single array.
Your best bet is therefore probably to use a list comprehension:
result = [coherent_dm(N=10, alpha=i, offset=0, method='operator') for i in c]