本文整理汇总了Python中sage.matrix.matrix_space.MatrixSpace._repr_option方法的典型用法代码示例。如果您正苦于以下问题:Python MatrixSpace._repr_option方法的具体用法?Python MatrixSpace._repr_option怎么用?Python MatrixSpace._repr_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.matrix.matrix_space.MatrixSpace
的用法示例。
在下文中一共展示了MatrixSpace._repr_option方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AlternatingSignMatrices
# 需要导入模块: from sage.matrix.matrix_space import MatrixSpace [as 别名]
# 或者: from sage.matrix.matrix_space.MatrixSpace import _repr_option [as 别名]
class AlternatingSignMatrices(Parent, UniqueRepresentation):
r"""
Class of all `n \times n` alternating sign matrices.
An alternating sign matrix of size `n` is an `n \times n` matrix of `0`s,
`1`s and `-1`s such that the sum of each row and column is `1` and the
non-zero entries in each row and column alternate in sign.
Alternating sign matrices of size `n` are in bijection with
:class:`monotone triangles <MonotoneTriangles>` with `n` rows.
INPUT:
- `n` -- an integer, the size of the matrices.
- ``use_monotone_triangle`` -- (Default: ``True``) If ``True``, the
generation of the matrices uses monotone triangles, else it will use the
earlier and now obsolete contre-tableaux implementation;
must be ``True`` to generate a lattice (with the ``lattice`` method)
EXAMPLES:
This will create an instance to manipulate the alternating sign
matrices of size 3::
sage: A = AlternatingSignMatrices(3)
sage: A
Alternating sign matrices of size 3
sage: A.cardinality()
7
Notably, this implementation allows to make a lattice of it::
sage: L = A.lattice()
sage: L
Finite lattice containing 7 elements
sage: L.category()
Category of facade finite lattice posets
"""
def __init__(self, n, use_monotone_triangles=True):
r"""
Initialize ``self``.
TESTS::
sage: A = AlternatingSignMatrices(4)
sage: TestSuite(A).run()
sage: A == AlternatingSignMatrices(4, use_monotone_triangles=False)
False
"""
self._n = n
self._matrix_space = MatrixSpace(ZZ, n)
self._umt = use_monotone_triangles
Parent.__init__(self, category=FiniteEnumeratedSets())
def _repr_(self):
r"""
Return a string representation of ``self``.
TESTS::
sage: A = AlternatingSignMatrices(4); A
Alternating sign matrices of size 4
"""
return "Alternating sign matrices of size %s" % self._n
def _repr_option(self, key):
"""
Metadata about the :meth:`_repr_` output.
See :meth:`sage.structure.parent._repr_option` for details.
EXAMPLES::
sage: A = AlternatingSignMatrices(3)
sage: A._repr_option('element_ascii_art')
True
"""
return self._matrix_space._repr_option(key)
def __contains__(self, asm):
"""
Check if ``asm`` is in ``self``.
TESTS::
sage: A = AlternatingSignMatrices(3)
sage: [[0,1,0],[1,0,0],[0,0,1]] in A
True
sage: [[0,1,0],[1,-1,1],[0,1,0]] in A
True
sage: [[0, 1],[1,0]] in A
False
sage: [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]] in A
False
sage: [[-1, 1, 1],[1,-1,1],[1,1,-1]] in A
False
"""
if isinstance(asm, AlternatingSignMatrix):
return asm._matrix.nrows() == self._n
#.........这里部分代码省略.........