I am trying to multiply a symbol with a matrix which is defined by QuTip quantum object, but I got this error:
TypeError: Incompatible object for multiplication
I used:
from qutip import *
import sympy as sp
w0 = sp.Symbol('\omega_{0}')
w0*destroy(4)
Did I miss something?
The object
destroy(4)contains a lot more information than just the matrix representation of the annihilation operator, so its represented as the typeQobjin qutip. The typeQobjcurrently doesn't support multiplication with the typesympy.Symbol. Note that you can look under the__rmul__method ofQobjto find which types are supported for multiplying withQobjon the right.If you're happy working with the matrix representations of these operators you could do the following to multiply a symbol with the matrix corresponding to
destroy(4). The following will work:This will be a numpy matrix containing symbols, and you can multiply it with the matrices corresponding to other operators in your calculation (at a great loss of efficiency!).
Otherwise this might be worth posting an issue on their github. An implementation might be possible based on how
__rmul__is dispatched tonumbers.Numberhere.