本文整理匯總了Python中sage.matrix.matrix_space.MatrixSpace.zero方法的典型用法代碼示例。如果您正苦於以下問題:Python MatrixSpace.zero方法的具體用法?Python MatrixSpace.zero怎麽用?Python MatrixSpace.zero使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sage.matrix.matrix_space.MatrixSpace
的用法示例。
在下文中一共展示了MatrixSpace.zero方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: to_matrix
# 需要導入模塊: from sage.matrix.matrix_space import MatrixSpace [as 別名]
# 或者: from sage.matrix.matrix_space.MatrixSpace import zero [as 別名]
def to_matrix(self):
r"""
Return ``self`` as a matrix.
We define a matrix `M_{xy} = \alpha(x, y)` for some element
`\alpha \in I_P` in the incidence algebra `I_P` and we order
the elements `x,y \in P` by some linear extension of `P`. This
defines an algebra (iso)morphism; in particular, multiplication
in the incidence algebra goes to matrix multiplication.
EXAMPLES::
sage: P = posets.BooleanLattice(2)
sage: I = P.incidence_algebra(QQ)
sage: I.moebius().to_matrix()
[ 1 -1 -1 1]
[ 0 1 0 -1]
[ 0 0 1 -1]
[ 0 0 0 1]
sage: I.zeta().to_matrix()
[1 1 1 1]
[0 1 0 1]
[0 0 1 1]
[0 0 0 1]
TESTS:
We check that this is an algebra (iso)morphism::
sage: P = posets.BooleanLattice(4)
sage: I = P.incidence_algebra(QQ)
sage: mu = I.moebius()
sage: (mu*mu).to_matrix() == mu.to_matrix() * mu.to_matrix()
True
"""
P = self.parent()
MS = MatrixSpace(P.base_ring(), P._poset.cardinality(), sparse=True)
L = P._linear_extension
M = copy(MS.zero())
for i, c in self:
M[L.index(i[0]), L.index(i[1])] = c
M.set_immutable()
return M
示例2: __call__
# 需要導入模塊: from sage.matrix.matrix_space import MatrixSpace [as 別名]
# 或者: from sage.matrix.matrix_space.MatrixSpace import zero [as 別名]
def __call__(self, A, name=''):
r"""
Create an element of the homspace ``self`` from `A`.
INPUT:
- ``A`` -- one of the following:
- an element of a Hecke algebra
- a Hecke module morphism
- a matrix
- a list of elements of the codomain specifying the images
of the basis elements of the domain.
EXAMPLES::
sage: M = ModularForms(Gamma0(7), 4)
sage: H = M.Hom(M)
sage: H(M.hecke_operator(7))
Hecke module morphism T_7 defined by the matrix
[ -7 0 0]
[ 0 1 240]
[ 0 0 343]
Domain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
Codomain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
sage: H(H(M.hecke_operator(7)))
Hecke module morphism T_7 defined by the matrix
[ -7 0 0]
[ 0 1 240]
[ 0 0 343]
Domain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
Codomain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
sage: H(matrix(QQ, 3, srange(9)))
Hecke module morphism defined by the matrix
[0 1 2]
[3 4 5]
[6 7 8]
Domain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
Codomain: Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) ...
TESTS:
Make sure that the element is created correctly when the codomain is
not the full module (related to :trac:`21497`)::
sage: M = ModularSymbols(Gamma0(3),weight=22,sign=1)
sage: S = M.cuspidal_subspace()
sage: H = S.Hom(S)
sage: H(S.gens())
Hecke module morphism defined by the matrix
[1 0 0 0 0 0]
[0 1 0 0 0 0]
[0 0 1 0 0 0]
[0 0 0 1 0 0]
[0 0 0 0 1 0]
[0 0 0 0 0 1]
Domain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
Codomain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
sage: H.zero() in H
True
sage: H.one() in H
True
"""
try:
if A.parent() == self:
A._set_parent(self)
return A
A = A.hecke_module_morphism()
if A.parent() == self:
A._set_parent(self)
return A
else:
raise TypeError("unable to coerce A to self")
except AttributeError:
pass
if A in self.base_ring():
dim_dom = self.domain().rank()
dim_codom = self.codomain().rank()
MS = MatrixSpace(self.base_ring(), dim_dom, dim_codom)
if self.domain() == self.codomain():
A = A * MS.identity_matrix()
elif A == 0:
A = MS.zero()
else:
raise ValueError('scalars do not coerce to this homspace')
elif isinstance(A, (list, tuple)):
A = matrix([self.codomain().coordinate_vector(f) for f in A])
return HeckeModuleMorphism_matrix(self, A, name)