Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the function mpsmpo.mpo_to_pmps() for rank-1 MPOs #52

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added mpo_to_pmps()
  • Loading branch information
Moritz Lange committed Dec 15, 2017
commit e86dbde9e09ae94f400cc91bf2a78c1009be277b
17 changes: 16 additions & 1 deletion mpnum/mpsmpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@
from . import mparray as mp
from .utils import local_to_global, matdot

from scipy.linalg import eigh

__all__ = ['mps_to_mpo', 'mps_to_pmps', 'pmps_dm_to_array',
'pmps_reduction', 'pmps_to_mpo', 'pmps_to_mps',
'pmps_reduction', 'mpo_to_pmps', 'pmps_to_mpo', 'pmps_to_mps',
'reductions_mpo', 'reductions_mps_as_mpo',
'reductions_mps_as_pmps', 'reductions_pmps', 'reductions']

Expand Down Expand Up @@ -372,6 +373,20 @@ def pmps_to_mpo(pmps):
return mp.dot(pmps, pmps.adj())


def mpo_to_pmps(mpo):
"""Convert a tensor product MPO into a local purification MPS mixed state.

:param MPArray mpo: An MPA with two physical legs and rank one on all sites
:returns: An MPA with two physical legs (system and ancilla)

"""
assert_array_equal(mpo.ranks, 1)
eigs = (eigh(lten[0, ..., 0]) for lten in mpo.lt)
ltens = (i[1] * np.sqrt(i[0])[None, ...] for i in eigs)
pmps = mp.MPArray.from_kron(ltens)
return pmps / mp.norm(pmps)


def mps_to_pmps(mps):
"""Convert a pure MPS into a local purification MPS mixed state.

Expand Down