common.py 文件源码

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

项目:qmflows-namd 作者: SCM-NV 项目源码 文件源码
def triang2mtx(xs: Vector, dim: int) -> Matrix:
    """
    Transform a symmetric matrix represented as a flatten upper triangular
    matrix to the correspoding 2-dimensional array.
    """
    # New array
    mtx = np.zeros((dim, dim))
    # indexes of the upper triangular
    inds = np.triu_indices_from(mtx)
    # Fill the upper triangular of the new array
    mtx[inds] = xs
    # Fill the lower triangular
    mtx[(inds[1], inds[0])] = xs

    return mtx
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号