Hi, apologies for the spate of questions. This will hopefully be the last for a while.
My goal is to apply a quantum channel to a density matrix represented as an MPO. Now, ordinarily, I would simply use apply() here. However, in this case the number of input and output indices is different. For example, you could think of this as a (non-unitary) quantum channel that ties together 4 sites into 1. Here is my best guess for how something like that might work:
function apply_channel(ρ::MPO, Ψ::ITensor)
ρ̃ = copy(ρ)
# extract the common indices where we will be applying the channel
common_inds = findall(x -> hascommoninds(Ψ, ρ[x]), collect(1:length(ρ)))
# Apply the channel
wf = ρ̃[common_inds[1]] * Ψ
for v in common_inds[2:end]
wf *= ρ̃[v]
end
# Update the MPO
new_data = vcat(ρ̃[1:common_inds[1]-1], wf, ρ̃[common_inds[end]+1:length(ρ̃)])
ρ̃.data = new_data
return ρ̃
end
I have no real reason to believe that this is wrong, save for the fact that my code as a whole is not working and I am trying to pinpoint the location of my bug. Please let me know if you have any thoughts! And thank you again for all the help.