本文整理汇总了Python中sage.modules.free_module.VectorSpace.base_ring方法的典型用法代码示例。如果您正苦于以下问题:Python VectorSpace.base_ring方法的具体用法?Python VectorSpace.base_ring怎么用?Python VectorSpace.base_ring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.modules.free_module.VectorSpace
的用法示例。
在下文中一共展示了VectorSpace.base_ring方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: linear_transformation
# 需要导入模块: from sage.modules.free_module import VectorSpace [as 别名]
# 或者: from sage.modules.free_module.VectorSpace import base_ring [as 别名]
#.........这里部分代码省略.........
...
ValueError: symbolic function has the wrong number of outputs for codomain
sage: x, y = var('x y')
sage: f(x, y) = [y, x*y]
sage: linear_transformation(QQ^2, QQ^2, f)
Traceback (most recent call last):
...
ValueError: symbolic function must be linear in all the inputs:
unable to convert y to a rational
sage: x, y = var('x y')
sage: f(x, y) = [x, 2*y]
sage: C = (QQ^2).span([vector(QQ, [1, 1])])
sage: linear_transformation(QQ^2, C, f)
Traceback (most recent call last):
...
ArithmeticError: some image of the function is not in the codomain, because
element [1, 0] is not in free module
"""
from sage.matrix.constructor import matrix
from sage.modules.module import is_VectorSpace
from sage.modules.free_module import VectorSpace
from sage.categories.homset import Hom
from sage.symbolic.ring import SymbolicRing
from sage.modules.vector_callable_symbolic_dense import Vector_callable_symbolic_dense
from inspect import isfunction
if not side in ['left', 'right']:
raise ValueError("side must be 'left' or 'right', not {0}".format(side))
if not (is_Matrix(arg0) or is_VectorSpace(arg0)):
raise TypeError('first argument must be a matrix or a vector space, not {0}'.format(arg0))
if is_Matrix(arg0):
R = arg0.base_ring()
if not R.is_field():
try:
R = R.fraction_field()
except (NotImplementedError, TypeError):
msg = 'matrix must have entries from a field, or a ring with a fraction field, not {0}'
raise TypeError(msg.format(R))
if side == 'right':
arg0 = arg0.transpose()
side = 'left'
arg2 = arg0
arg0 = VectorSpace(R, arg2.nrows())
arg1 = VectorSpace(R, arg2.ncols())
elif is_VectorSpace(arg0):
if not is_VectorSpace(arg1):
msg = 'if first argument is a vector space, then second argument must be a vector space, not {0}'
raise TypeError(msg.format(arg1))
if arg0.base_ring() != arg1.base_ring():
msg = 'vector spaces must have the same field of scalars, not {0} and {1}'
raise TypeError(msg.format(arg0.base_ring(), arg1.base_ring()))
# Now arg0 = domain D, arg1 = codomain C, and
# both are vector spaces with common field of scalars
# use these to make a VectorSpaceHomSpace
# arg2 might be a matrix that began in arg0
D = arg0
C = arg1
H = Hom(D, C, category=None)
# Examine arg2 as the "rule" for the linear transformation
# Pass on matrices, Python functions and lists to homspace call
# Convert symbolic function here, to a matrix
if is_Matrix(arg2):