本文整理汇总了Python中sage.matrix.matrix_space.MatrixSpace.columns方法的典型用法代码示例。如果您正苦于以下问题:Python MatrixSpace.columns方法的具体用法?Python MatrixSpace.columns怎么用?Python MatrixSpace.columns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.matrix.matrix_space.MatrixSpace
的用法示例。
在下文中一共展示了MatrixSpace.columns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: algebraic_topological_model_delta_complex
# 需要导入模块: from sage.matrix.matrix_space import MatrixSpace [as 别名]
# 或者: from sage.matrix.matrix_space.MatrixSpace import columns [as 别名]
#.........这里部分代码省略.........
for n in range(-1, K.dimension()+1):
gens[n] = []
C = K.chain_complex(base_ring=base_ring)
n_cells = []
pi_cols = []
iota_cols = {}
for dim in range(K.dimension()+1):
# old_cells: cells one dimension lower.
old_cells = n_cells
# n_cells: the standard basis for the vector space C.free_module(dim).
n_cells = C.free_module(dim).gens()
diff = C.differential(dim)
# diff is sparse and low density. Dense matrices are faster
# over finite fields, but for low density matrices, sparse
# matrices are faster over the rationals.
if base_ring != QQ:
diff = diff.dense_matrix()
rank = len(n_cells)
old_rank = len(old_cells)
# Create some matrix spaces to try to speed up matrix creation.
MS_pi_t = MatrixSpace(base_ring, old_rank, len(gens[dim-1]))
pi_old = MS_pi_t.matrix(pi_cols).transpose()
iota_cols_old = iota_cols
iota_cols = {}
pi_cols_old = pi_cols
pi_cols = []
phi_old = MatrixSpace(base_ring, rank, old_rank, sparse=(base_ring==QQ)).zero()
phi_old_cols = phi_old.columns()
phi_old = conditionally_sparse(phi_old)
to_be_deleted = []
zero_vector = vector(base_ring, rank)
pi_nrows = pi_old.nrows()
for c_idx, c in enumerate(n_cells):
# c_bar = c - phi(bdry(c)):
# Avoid a bug in matrix-vector multiplication (trac 19378):
if not diff:
c_bar = c
pi_bdry_c_bar = False
else:
if base_ring == QQ:
c_bar = c - phi_old * (diff * c)
pi_bdry_c_bar = conditionally_sparse(pi_old) * (diff * c_bar)
else:
c_bar = c - phi_old * diff * c
pi_bdry_c_bar = conditionally_sparse(pi_old) * diff * c_bar
# One small typo in the published algorithm: it says
# "if bdry(c_bar) == 0", but should say
# "if pi(bdry(c_bar)) == 0".
if not pi_bdry_c_bar:
# Append c to list of gens.
gens[dim].append(c_idx)
# iota(c) = c_bar
iota_cols[c_idx] = c_bar
# pi(c) = c
pi_cols.append(c)
else:
# Take any u in gens so that lambda_i = <u, pi(bdry(c_bar))> != 0.