onedim_utils.py 文件源码

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

项目:tncontract 作者: andrewdarmawan 项目源码 文件源码
def init_mps_logical(nsites, basis_state, physdim, left_label='left',
                     right_label='right', phys_label='phys'):
    """
    Create an MPS with `nsites` sites in the logical basis state |ijk..l>.

    Parameters
    ----------
    nsites : int
    basis_state : int or list of ints
        Site `i` will be in the state |`basis_state[i]`> (or simply
        |`basis_state`> if a single int is provided).
    physdim : int or list of ints
    left_label : str
    right_label : str
    phys_label : str
    """
    if not np.iterable(physdim):
        physdim = [physdim] * nsites

    tensors = []
    for j in range(nsites):
        t = np.zeros(physdim[j])
        t[basis_state[j]] = 1.0
        t = tnc.Tensor(t.reshape(physdim[j], 1, 1), [phys_label, left_label,
                                                     right_label])
        tensors.append(t)

    return onedim.MatrixProductState(tensors, left_label=left_label,
                                     right_label=right_label, phys_label=phys_label)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号