GTorlai / PastaQ.jl

Package for Simulation, Tomography and Analysis of Quantum Computers
Apache License 2.0
142 stars 23 forks source link

Add `choitags` function #181

Closed mtfishman closed 3 years ago

mtfishman commented 3 years ago

Add a function that makes it easier to convert back and forth between the standard ITensor MPO priming convention and the tag convention for Choi matrices. For example:

function choitags(U::Union{MPS, MPO})
  U = copy(U)
  haschoitags(U) && return U
  U = addtags(siteinds, U, "Input"; plev = 0)
  U = addtags(siteinds, U, "Output"; plev = 1)
  return noprime(U)
end

function mpotags(U::Union{MPS, MPO})
  U = copy(U)
  hasmpotags(U) && return U
  U = prime(U; tags="Output")
  U = removetags(U, "Input")
  U = removetags(U, "Output")
  return U
end

Then, a Choi LPDO can be made from a unitary MPO with:

choi = LPDO(convert(MPS, choitags(U)))

and a unitary MPO can be made from a Choi LPDO with:

choi = convert(MPO, mpotags(choi.X)))

These could be wrapped in functions like:

unitary_mpo_to_choi_lpdo(U::MPO) = LPDO(convert(MPS, choitags(U)))
choi_lpdo_to_unitary_mpo(choi::LPDO) = convert(MPO, mpotags(choi.X)))