本文整理匯總了Python中sage.matrix.matrix_space.MatrixSpace.matrix方法的典型用法代碼示例。如果您正苦於以下問題:Python MatrixSpace.matrix方法的具體用法?Python MatrixSpace.matrix怎麽用?Python MatrixSpace.matrix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sage.matrix.matrix_space.MatrixSpace
的用法示例。
在下文中一共展示了MatrixSpace.matrix方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: algebraic_topological_model_delta_complex
# 需要導入模塊: from sage.matrix.matrix_space import MatrixSpace [as 別名]
# 或者: from sage.matrix.matrix_space.MatrixSpace import matrix [as 別名]
def algebraic_topological_model_delta_complex(K, base_ring=None):
r"""
Algebraic topological model for cell complex ``K``
with coefficients in the field ``base_ring``.
This has the same basic functionality as
:func:`algebraic_topological_model`, but it also works for
`\Delta`-complexes. For simplicial and cubical complexes it is
somewhat slower, though.
INPUT:
- ``K`` -- a simplicial complex, a cubical complex, or a
`\Delta`-complex
- ``base_ring`` -- coefficient ring; must be a field
OUTPUT: a pair ``(phi, M)`` consisting of
- chain contraction ``phi``
- chain complex `M`
See :func:`algebraic_topological_model` for the main
documentation. The difference in implementation between the two:
this uses matrix and vector algebra. The other function does more
of the computations "by hand" and uses cells (given as simplices
or cubes) to index various dictionaries. Since the cells in
`\Delta`-complexes are not as nice, the other function does not
work for them, while this function relies almost entirely on the
structure of the associated chain complex.
EXAMPLES::
sage: from sage.homology.algebraic_topological_model import algebraic_topological_model_delta_complex as AT_model
sage: RP2 = simplicial_complexes.RealProjectivePlane()
sage: phi, M = AT_model(RP2, GF(2))
sage: M.homology()
{0: Vector space of dimension 1 over Finite Field of size 2,
1: Vector space of dimension 1 over Finite Field of size 2,
2: Vector space of dimension 1 over Finite Field of size 2}
sage: T = delta_complexes.Torus()
sage: phi, M = AT_model(T, QQ)
sage: M.homology()
{0: Vector space of dimension 1 over Rational Field,
1: Vector space of dimension 2 over Rational Field,
2: Vector space of dimension 1 over Rational Field}
If you want to work with cohomology rather than homology, just
dualize the outputs of this function::
sage: M.dual().homology()
{0: Vector space of dimension 1 over Rational Field,
1: Vector space of dimension 2 over Rational Field,
2: Vector space of dimension 1 over Rational Field}
sage: M.dual().degree_of_differential()
1
sage: phi.dual()
Chain homotopy between:
Chain complex endomorphism of Chain complex with at most 3 nonzero terms over Rational Field
and Chain complex morphism:
From: Chain complex with at most 3 nonzero terms over Rational Field
To: Chain complex with at most 3 nonzero terms over Rational Field
In degree 0, the inclusion of the homology `M` into the chain
complex `C` sends the homology generator to a single vertex::
sage: K = delta_complexes.Simplex(2)
sage: phi, M = AT_model(K, QQ)
sage: phi.iota().in_degree(0)
[0]
[0]
[1]
In cohomology, though, one needs the dual of every degree 0 cell
to detect the degree 0 cohomology generator::
sage: phi.dual().iota().in_degree(0)
[1]
[1]
[1]
TESTS::
sage: T = cubical_complexes.Torus()
sage: C = T.chain_complex()
sage: H, M = AT_model(T, QQ)
sage: C.differential(1) * H.iota().in_degree(1).column(0) == 0
True
sage: C.differential(1) * H.iota().in_degree(1).column(1) == 0
True
sage: coC = T.chain_complex(cochain=True)
sage: coC.differential(1) * H.dual().iota().in_degree(1).column(0) == 0
True
sage: coC.differential(1) * H.dual().iota().in_degree(1).column(1) == 0
True
"""
def conditionally_sparse(m):
"""
Return a sparse matrix if the characteristic is zero.
Multiplication of matrices with low density seems to be quicker
#.........這裏部分代碼省略.........