I am new to QuTiP. While trying a simple exercise, I encountered a problem with matrix products. It's something quite elementary but I can't figure it out yet.
I start with these states.
h = basis(2,0)
v = basis(2,1)
psi_a = 1/np.sqrt(2) * ( h + v )
psi_b = 1/np.sqrt(2) * ( h + v )
Then take the tensor product.
psi_ab_t0 = tensor(psi_a,psi_b)
which gives:
Quantum object: dims = [[2, 2], [1, 1]], shape = [4, 1], type = ket
Qobj data =
[[ 0.5]
[ 0.5]
[ 0.5]
[ 0.5]]
I take a simple hamiltonian.
hmlt = Qobj([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,-1]])
hmltpr = (-1j*np.pi/2) * hmlt
hmlt_tf = hmltpr.expm()
Now I need to do apply the hamiltonian hmlt_tf to the state psi_ab_t0.
But the matrix product does not work because the dimensions for hmlt_tf are [[4], [4]] and dimensions for psi_ab_t0 are [[2, 2], [1, 1]].
I can convert them to numpy arrays and multiply them but there's a problem. I need to measure concurrence at the end which takes a tensor product as its input.
The only way I can get it to work right now is to manually change psi_ab_t0.dims to [[4], [4]] and then back after I've taken the matrix product. This is obviously an ugly hack. What is the preferred way of doing this?