本文整理汇总了Python中sage.matrix.constructor.Matrix.base_ring方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.base_ring方法的具体用法?Python Matrix.base_ring怎么用?Python Matrix.base_ring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.matrix.constructor.Matrix
的用法示例。
在下文中一共展示了Matrix.base_ring方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Matroid
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import base_ring [as 别名]
#.........这里部分代码省略.........
3
We automatically create an optimized subclass, if available::
sage: Matroid([0, 1, 2, 3, 4, 5],
....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]],
....: field=GF(2))
Binary matroid of rank 3 on 6 elements, type (2, 7)
sage: Matroid([0, 1, 2, 3, 4, 5],
....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]],
....: field=GF(3))
Ternary matroid of rank 3 on 6 elements, type 0-
sage: Matroid([0, 1, 2, 3, 4, 5],
....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]],
....: field=GF(4, 'x'))
Quaternary matroid of rank 3 on 6 elements
sage: Matroid([0, 1, 2, 3, 4, 5],
....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]],
....: field=GF(2), regular=True)
Regular matroid of rank 3 on 6 elements with 16 bases
Otherwise the generic LinearMatroid class is used::
sage: Matroid([0, 1, 2, 3, 4, 5],
....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]],
....: field=GF(83))
Linear matroid of rank 3 on 6 elements represented over the Finite
Field of size 83
An integer matrix is automatically converted to a matrix over `\QQ`.
If you really want integers, you can specify the ring explicitly::
sage: A = Matrix([[1, 1, 0], [1, 0, 1], [0, 1, -1]])
sage: A.base_ring()
Integer Ring
sage: M = Matroid([0, 1, 2, 3, 4, 5], A)
sage: M.base_ring()
Rational Field
sage: M = Matroid([0, 1, 2, 3, 4, 5], A, ring=ZZ)
sage: M.base_ring()
Integer Ring
#. Rank function:
Any function mapping subsets to integers can be used as input::
sage: def f(X):
....: return min(len(X), 2)
sage: M = Matroid('abcd', rank_function=f)
sage: M
Matroid of rank 2 on 4 elements
sage: M.is_isomorphic(matroids.Uniform(2, 4))
True
#. Circuit closures:
This is often a really concise way to specify a matroid. The usual way
is a dictionary of lists::
sage: M = Matroid(circuit_closures={3: ['edfg', 'acdg', 'bcfg',
....: 'cefh', 'afgh', 'abce', 'abdf', 'begh', 'bcdh', 'adeh'],
....: 4: ['abcdefgh']})
sage: M.equals(matroids.named_matroids.P8())
True
You can also input tuples `(k, X)` where `X` is the closure of a
示例2: Matroid
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import base_ring [as 别名]
#.........这里部分代码省略.........
3
We automatically create an optimized subclass, if available::
sage: Matroid([0, 1, 2, 3, 4, 5],
....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]],
....: field=GF(2))
Binary matroid of rank 3 on 6 elements, type (2, 7)
sage: Matroid([0, 1, 2, 3, 4, 5],
....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]],
....: field=GF(3))
Ternary matroid of rank 3 on 6 elements, type 0-
sage: Matroid([0, 1, 2, 3, 4, 5],
....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]],
....: field=GF(4, 'x'))
Quaternary matroid of rank 3 on 6 elements
sage: Matroid([0, 1, 2, 3, 4, 5],
....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]],
....: field=GF(2), regular=True)
Regular matroid of rank 3 on 6 elements with 16 bases
Otherwise the generic LinearMatroid class is used::
sage: Matroid([0, 1, 2, 3, 4, 5],
....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]],
....: field=GF(83))
Linear matroid of rank 3 on 6 elements represented over the Finite
Field of size 83
An integer matrix is automatically converted to a matrix over `\QQ`.
If you really want integers, you can specify the ring explicitly::
sage: A = Matrix([[1, 1, 0], [1, 0, 1], [0, 1, -1]])
sage: A.base_ring()
Integer Ring
sage: M = Matroid([0, 1, 2, 3, 4, 5], A)
sage: M.base_ring()
Rational Field
sage: M = Matroid([0, 1, 2, 3, 4, 5], A, ring=ZZ)
sage: M.base_ring()
Integer Ring
#. Rank function:
Any function mapping subsets to integers can be used as input::
sage: def f(X):
....: return min(len(X), 2)
....:
sage: M = Matroid('abcd', rank_function=f)
sage: M
Matroid of rank 2 on 4 elements
sage: M.is_isomorphic(matroids.Uniform(2, 4))
True
#. Circuit closures:
This is often a really concise way to specify a matroid. The usual way
is a dictionary of lists::
sage: M = Matroid(circuit_closures={3: ['edfg', 'acdg', 'bcfg',
....: 'cefh', 'afgh', 'abce', 'abdf', 'begh', 'bcdh', 'adeh'],
....: 4: ['abcdefgh']})
sage: M.equals(matroids.named_matroids.P8())
True