def _embed_ltens_identity(mpa, embed_tensor=None):
"""Embed with identity matrices by default.
:param embed_tensor: If the MPAs do not have two physical legs or
have non-square physical dimensions, you must provide an
embedding tensor. The default is to use the square identity
matrix, assuming that the size of the two physical legs is the
same at each site.
:returns: `embed_tensor` with one size-one virtual leg added at each
end.
"""
if embed_tensor is None:
pdims = mpa.shape[0]
assert len(pdims) == 2 and pdims[0] == pdims[1], (
"For ndims != 2 or non-square shape, you must supply a tensor"
"for embedding")
embed_tensor = np.eye(pdims[0])
embed_ltens = embed_tensor[None, ..., None]
return embed_ltens
评论列表
文章目录