当前位置: 首页>>代码示例>>Python>>正文


Python MatrixUtil.assert_square方法代码示例

本文整理汇总了Python中MatrixUtil.assert_square方法的典型用法代码示例。如果您正苦于以下问题:Python MatrixUtil.assert_square方法的具体用法?Python MatrixUtil.assert_square怎么用?Python MatrixUtil.assert_square使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MatrixUtil的用法示例。


在下文中一共展示了MatrixUtil.assert_square方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dccov_to_edm

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def dccov_to_edm(HSH):
    """
    @param HSH: a double centered covariance matrix
    @return: a Euclidean distance matrix
    """
    MatrixUtil.assert_square(HSH)
    return cov_to_edm(HSH)
开发者ID:argriffing,项目名称:xgcode,代码行数:9,代码来源:Euclid.py

示例2: adjacency_to_laplacian

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def adjacency_to_laplacian(A):
    """
    @param A: an adjacency matrix
    @return: a laplacian matrix
    """
    MatrixUtil.assert_square(A)
    return np.diag(np.sum(A, 0)) - A
开发者ID:argriffing,项目名称:xgcode,代码行数:9,代码来源:Euclid.py

示例3: laplacian_to_edm

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def laplacian_to_edm(L):
    """
    @param L: a laplacian matrix
    @return: a Euclidean distance matrix
    """
    MatrixUtil.assert_square(L)
    return dccov_to_edm(laplacian_to_dccov(L))
开发者ID:argriffing,项目名称:xgcode,代码行数:9,代码来源:Euclid.py

示例4: laplacian_to_adjacency

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def laplacian_to_adjacency(L):
    """
    @param L: a laplacian matrix
    @return: an adjacency matrix
    """
    MatrixUtil.assert_square(L)
    return np.diag(np.diag(L)) - L
开发者ID:argriffing,项目名称:xgcode,代码行数:9,代码来源:Euclid.py

示例5: edm_to_dccov

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def edm_to_dccov(D):
    """
    @param D: a Euclidean distance matrix
    @return: a double centered covariance matrix
    """
    MatrixUtil.assert_square(D)
    return -(0.5)*MatrixUtil.double_centered(D)
开发者ID:argriffing,项目名称:xgcode,代码行数:9,代码来源:Euclid.py

示例6: q_to_cov

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def q_to_cov(Q):
    """
    @param Q: a neighbor joining Q matrix
    @return: something like a covariance matrix
    """
    MatrixUtil.assert_square(Q)
    n = len(Q)
    S = -Q/(2*(n-2))
    return S
开发者ID:argriffing,项目名称:xgcode,代码行数:11,代码来源:Euclid.py

示例7: bott_duffin_const

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def bott_duffin_const(M):
    """
    Compute a constrained generalized inverse.
    Specifically, this is the Bott-Duffin inverse of M
    constrained to the orthogonal complement of the constant vector.
    """
    MatrixUtil.assert_square(M)
    n = len(M)
    e = np.ones(n)
    return bott_duffin(M, e)
开发者ID:argriffing,项目名称:xgcode,代码行数:12,代码来源:numpyutils.py

示例8: laplacian_to_dccov

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def laplacian_to_dccov(L):
    """
    @param L: a laplacian matrix
    @return: a double centered covariance matrix
    """
    MatrixUtil.assert_square(L)
    M = np.ones_like(L) / float(len(L))
    # This should be the same but perhaps not as numerically stable:
    # HSH = np.linalg.pinv(L)
    HSH = np.linalg.pinv(L - M) + M
    return HSH
开发者ID:argriffing,项目名称:xgcode,代码行数:13,代码来源:Euclid.py

示例9: cov_to_edm

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def cov_to_edm(S):
    """
    @param S: a covariance matrix
    @return: a Euclidean distance matrix
    """
    MatrixUtil.assert_square(S)
    n = len(S)
    d = np.diag(S)
    e = np.ones_like(d)
    D = np.outer(d, e) + np.outer(e, d) - 2*S
    return D
开发者ID:argriffing,项目名称:xgcode,代码行数:13,代码来源:Euclid.py

示例10: edm_to_q

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def edm_to_q(D):
    """
    @param D: a treelike distance matrix
    @return: the neighbor joining Q matrix
    """
    MatrixUtil.assert_square(D)
    n = len(D)
    r = np.sum(D, 0)
    e = np.ones_like(r)
    Q = (n-2)*D - np.outer(e, r) - np.outer(r, e)
    return Q
开发者ID:argriffing,项目名称:xgcode,代码行数:13,代码来源:Euclid.py

示例11: dccov_to_laplacian

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def dccov_to_laplacian(HSH):
    """
    This function stably pseudoinverts a double centered matrix.
    @param HSH: a double centered covariance matrix
    @return: a laplacian matrix
    """
    MatrixUtil.assert_square(HSH)
    M = np.ones_like(HSH) / float(len(HSH))
    # This should be the same but perhaps not as numerically stable:
    # L = np.linalg.pinv(HSH)
    L = np.linalg.pinv(HSH - M) + M
    return L
开发者ID:argriffing,项目名称:xgcode,代码行数:14,代码来源:Euclid.py

示例12: edm_to_laplacian

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def edm_to_laplacian(D):
    """
    @param D: a Euclidean distance matrix
    @return: a laplacian matrix
    """
    MatrixUtil.assert_square(D)
    D_pinv = np.linalg.pinv(D)
    a = np.sum(D_pinv, 0)
    denom = np.sum(D_pinv)
    if not denom:
        raise ValueError('the EDM is not spherical')
    L = -2.0*(D_pinv - np.outer(a,a)/denom)
    return L
开发者ID:argriffing,项目名称:xgcode,代码行数:15,代码来源:Euclid.py

示例13: dccov_to_q

# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import assert_square [as 别名]
def dccov_to_q(HSH):
    """
    Is there a shortcut here?
    @param HSH: a doubly centered covariance matrix
    @return: a neighbor joining Q matrix
    """
    MatrixUtil.assert_square(HSH)
    n = len(HSH)
    d = np.diag(HSH)
    e = np.ones_like(d)
    D = np.outer(d, e) + np.outer(e, d) - 2*HSH
    r = np.sum(D, 0)
    e = np.ones_like(r)
    Q = (n-2)*D - np.outer(e, r) - np.outer(r, e)
    return Q
开发者ID:argriffing,项目名称:xgcode,代码行数:17,代码来源:Euclid.py


注:本文中的MatrixUtil.assert_square方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。