def split(self, pos):
"""Splits the MPA into two by transforming the virtual legs into
local legs according to :func:`vleg2leg`.
:param pos: Number of the virtual to perform the transformation
:returns: (mpa_left, mpa_right)
"""
if pos < 0:
return None, self
elif pos >= len(self):
return self, None
mpa_t = self.vleg2leg(pos)
lnorm, rnorm = mpa_t.canonical_form
ltens_l = LocalTensors(it.islice(mpa_t.lt, 0, pos + 1),
cform=(min(lnorm, pos), min(rnorm, pos + 1)))
ltens_r = LocalTensors(it.islice(mpa_t.lt, pos + 1, len(mpa_t)),
cform=(max(0, lnorm - pos), max(0, rnorm - pos - 1)))
return type(self)(ltens_l), type(self)(ltens_r)
评论列表
文章目录