mparray.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:mpnum 作者: dseuss 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号