本文整理汇总了Python中MatrixUtil.get_principal_submatrix方法的典型用法代码示例。如果您正苦于以下问题:Python MatrixUtil.get_principal_submatrix方法的具体用法?Python MatrixUtil.get_principal_submatrix怎么用?Python MatrixUtil.get_principal_submatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixUtil
的用法示例。
在下文中一共展示了MatrixUtil.get_principal_submatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_subtree_messages
# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import get_principal_submatrix [as 别名]
def get_subtree_messages(D, eigensplit, ordered_tip_names):
"""
@param D: the matrix of pairwise distances among tips of the tree
@param eigensplit: the split induced by the fiedler vector
@param ordered_tip_names: names of the tips of the tree conformant to v and D
@return: a multi-line string
"""
out = StringIO()
n = len(D)
ordered_label_sets = [set([i]) for i in range(n)]
all_labels = set(range(n))
for i, child in enumerate(eigensplit):
complement = all_labels - child
D_child = MatrixUtil.get_principal_submatrix(D, list(sorted(child)))
child_label_sets = SchurAlgebra.vdelete(ordered_label_sets, complement)
v_child = BuildTreeTopology.edm_to_fiedler(D_child)
print >> out, 'the Fiedler split of Schur complements of subtree', i+1
for label_set, value in zip(child_label_sets, v_child):
s = label_set_to_string(label_set, ordered_tip_names)
print >> out, s, ':', value
print >> out
return out.getvalue().strip()