本文整理汇总了Python中sage.symbolic.ring.SymbolicRing类的典型用法代码示例。如果您正苦于以下问题:Python SymbolicRing类的具体用法?Python SymbolicRing怎么用?Python SymbolicRing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SymbolicRing类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _latex_element_
def _latex_element_(self, x):
r"""
Finds the LaTeX representation of this expression.
EXAMPLES::
sage: f(A, t, omega, psi) = A*cos(omega*t - psi)
sage: f._latex_()
'\\left( A, t, \\omega, \\psi \\right) \\ {\\mapsto} \\ A \\cos\\left(\\omega t - \\psi\\right)'
sage: f(mu) = mu^3
sage: f._latex_()
'\\mu \\ {\\mapsto}\\ \\mu^{3}'
"""
from sage.misc.latex import latex
args = self.args()
args = [latex(arg) for arg in args]
latex_x = SymbolicRing._latex_element_(self, x)
if len(args) == 1:
return r"%s \ {\mapsto}\ %s" % (args[0], latex_x)
else:
vars = ", ".join(args)
# the weird TeX is to workaround an apparent JsMath bug
return r"\left( %s \right) \ {\mapsto} \ %s" % (vars, latex_x)
示例2: __init__
def __init__(self, arguments):
"""
EXAMPLES:
We verify that coercion works in the case where ``x`` is not an
instance of SymbolicExpression, but its parent is still the
SymbolicRing::
sage: f(x) = 1
sage: f*e
x |--> e
TESTS::
sage: TestSuite(f.parent()).run(skip=['_test_divides'])
"""
self._arguments = arguments
SymbolicRing.__init__(self, SR)
self._populate_coercion_lists_(coerce_list=[SR])
self.symbols = SR.symbols # Use the same list of symbols as SR
示例3: _element_constructor_
def _element_constructor_(self, x):
"""
TESTS::
sage: f(x) = x+1; g(y) = y+1
sage: f.parent()(g)
x |--> y + 1
sage: g.parent()(f)
y |--> x + 1
sage: f(x) = x+2*y; g(y) = y+3*x
sage: f.parent()(g)
x |--> 3*x + y
sage: g.parent()(f)
y |--> x + 2*y
"""
return SymbolicRing._element_constructor_(self, x)
示例4: _coerce_map_from_
def _coerce_map_from_(self, R):
"""
EXAMPLES::
sage: f(x,y) = x^2 + y
sage: g(x,y,z) = x + y + z
sage: f.parent().has_coerce_map_from(g.parent())
False
sage: g.parent().has_coerce_map_from(f.parent())
True
"""
if is_CallableSymbolicExpressionRing(R):
args = self.arguments()
if all(a in args for a in R.arguments()):
return True
else:
return False
return SymbolicRing._coerce_map_from_(self, R)
示例5: _repr_element_
def _repr_element_(self, x):
"""
Returns the string representation of the Expression ``x``.
EXAMPLES::
sage: f(y,x) = x + y
sage: f
(y, x) |--> x + y
sage: f.parent()
Callable function ring with arguments (y, x)
"""
args = self.arguments()
repr_x = SymbolicRing._repr_element_(self, x)
if len(args) == 1:
return "%s |--> %s" % (args[0], repr_x)
else:
args = ", ".join(map(str, args))
return "(%s) |--> %s" % (args, repr_x)