mppovm.py 文件源码

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

项目:mpnum 作者: dseuss 项目源码 文件源码
def repeat(self, nr_sites):
        """Construct a longer MP-POVM by repetition

        The resulting POVM will have length `nr_sites`. If `nr_sites`
        is not an integer multiple of `len(self)`, `self` must
        factorize (have leg  dimension one) at the position where it
        will be cut. For example, consider the tensor product MP-POVM
        of Pauli X and Pauli Y. Calling `repeat(nr_sites=5)` will
        construct the tensor product POVM XYXYX:

        >>> import mpnum as mp
        >>> import mpnum.povm as mpp
        >>> x, y = (mpp.MPPovm.from_local_povm(lp(3), 1) for lp in
        ...         (mpp.x_povm, mpp.y_povm))
        >>> xy = mp.chain([x, y])
        >>> xyxyx = mp.chain([x, y, x, y, x])
        >>> mp.norm(xyxyx - xy.repeat(5)) <= 1e-10
        True

        """
        n_repeat, n_last = nr_sites // len(self), nr_sites % len(self)
        if n_last > 0:
            assert self.ranks[n_last - 1] == 1, \
                "Partial repetition requires factorizing MP-POVM"
        return mp.chain([self] * n_repeat
                        + ([MPPovm(self.lt[:n_last])] if n_last > 0 else []))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号