utils.py 文件源码

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

项目:vampyre 作者: GAMPTeam 项目源码 文件源码
def repeat_sum(u,shape,rep_axes):
    """
    Computes sum of a repeated matrix

    In effect, this routine computes 
    code:`np.sum(repeat(u,shape,rep_axes))`.  However, it performs
    this without having to perform the full repetition.

    """
    # Must convert to np.array to perform slicing
    shape_vec = np.array(shape,dtype=int)
    rep_vec = np.array(rep_axes,dtype=int)

    # repeat and sum
    urep = repeat_axes(u,shape,rep_axes,rep=False)
    usum = np.sum(urep)*np.product(shape_vec[rep_vec])
    return usum
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号