This was previously explored in QuTiP TypeError: Incompatible Qobj shapes with tensor product but I'm not sure about the answer there.
Suppose I define A = tensor(qeye(2), qeye(2)) and B = qeye(4), I cannot multiply them because the object shapes are inconsistent.
However, the matrices are of the same dimension and I would like to "flatten" A to allow it to be multiplied by B. If I have a combination of seperable operators and non-seperable ones, how do I use them together? In other words, B cannot be simplified further so what should I do to A to allow them to be multiplied?
EDIT: The clunky looking Qobj(A.data.toarray()) works but I'll leave this open in case someone has a better idea or understands why QuTiP does this.
Yes using
Qobj.datayou get the matrix representing the state or operator.Hence
A.data * B.dataallows you to multiply them together. Once you've done that you can enclose it inQobj(A.data * B.data)to make it a quantum object.