mparray.py 文件源码

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

项目:mpnum 作者: dseuss 项目源码 文件源码
def trace(mpa, axes=(0, 1)):
    """Compute the trace of the given MPA.

    If you specify axes (see partialtrace() for details), you must
    ensure that the result has no physical legs anywhere.

    :param mpa: MParray
    :param axes: Axes for trace, ``(axis1, axis2)`` or ``(axes1, axes2, ...)``
        with ``axesN=(axisN_1, axisN_2)`` or ``axesN=None``.
        (default: ``(0, 1)``)
    :returns: A single scalar of type ``mpa.dtype``

    """
    out = partialtrace(mpa, axes)
    out = out.to_array()
    assert out.size == 1, 'trace must return a single scalar'
    return out[None][0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号