本文整理汇总了Python中sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing._rmul_方法的典型用法代码示例。如果您正苦于以下问题:Python PolynomialRing._rmul_方法的具体用法?Python PolynomialRing._rmul_怎么用?Python PolynomialRing._rmul_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing
的用法示例。
在下文中一共展示了PolynomialRing._rmul_方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Polynomial_padic_capped_relative_dense
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import _rmul_ [as 别名]
#.........这里部分代码省略.........
sage: a = t^4 + 17*t^2 + 1
sage: b = -t^4 + 9*t^2 + 13*t - 1
sage: c = a + b; c
(O(13^7))*t^4 + (2*13 + O(13^7))*t^2 + (13 + O(13^8))*t + (O(13^7))
sage: d = R([K(1,4), K(2, 6), K(1, 5)]); d
(1 + O(13^5))*t^2 + (2 + O(13^6))*t + (1 + O(13^4))
sage: e = c * d; e
(O(13^7))*t^6 + (O(13^7))*t^5 + (2*13 + O(13^6))*t^4 + (5*13 + O(13^6))*t^3 + (4*13 + O(13^5))*t^2 + (13 + O(13^5))*t + (O(13^7))
sage: e.list()
[O(13^7),
13 + O(13^5),
4*13 + O(13^5),
5*13 + O(13^6),
2*13 + O(13^6),
O(13^7),
O(13^7)]
"""
self._normalize()
right._normalize()
zzpoly = self._poly * right._poly
if len(self._relprecs) == 0 or len(right._relprecs) == 0:
return self.parent()(0)
n = Integer(len(self._relprecs) + len(right._relprecs) - 1).exact_log(2) + 1
precpoly1 = self._getprecpoly(n) * right._getvalpoly(n)
precpoly2 = self._getvalpoly(n) * right._getprecpoly(n)
# These two will be the same length
tn = Integer(1) << n
preclist = [min(a.valuation(tn), b.valuation(tn)) for (a, b) in zip(precpoly1.list(), precpoly2.list())]
answer = Polynomial_padic_capped_relative_dense(self.parent(), (zzpoly, self._valbase + right._valbase, preclist, False, None, None), construct = True)
answer._reduce_poly()
return answer
def _lmul_(self, right):
return self._rmul_(right)
def _rmul_(self, left):
"""
Returns self multiplied by a constant
EXAMPLES:
sage: K = Qp(13,7)
sage: R.<t> = K[]
sage: a = t^4 + K(13,5)*t^2 + 13
sage: K(13,7) * a
(13 + O(13^7))*t^4 + (13^2 + O(13^6))*t^2 + (13^2 + O(13^8))
"""
return None
# The code below has never been tested and is somehow subtly broken.
if self._valaddeds is None:
self._comp_valaddeds()
if left != 0:
val, unit = left.val_unit()
left_rprec = left.precision_relative()
relprecs = [min(left_rprec + self._valaddeds[i], self._relprecs[i]) for i in range(len(self._relprecs))]
elif left._is_exact_zero():
return Polynomial_padic_capped_relative_dense(self.parent(), [])
else:
return Polynomial_padic_capped_relative_dense(self.parent(), (self._poly.parent()(0), self._valbase + left.valuation(), self._valaddeds, False, self._valaddeds, None), construct = True)
return Polynomial_padic_capped_relative_dense(self.parent(), (self._poly._rmul_(unit), self._valbase + val, relprecs, False, self._valaddeds, None), construct = True)
def _neg_(self):
"""
Returns the negation of self.
EXAMPLES:
示例2: Polynomial_padic_capped_relative_dense
# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import _rmul_ [as 别名]
#.........这里部分代码省略.........
sage: a = t^4 + 17*t^2 + 1
sage: b = -t^4 + 9*t^2 + 13*t - 1
sage: c = a + b; c
(O(13^7))*t^4 + (2*13 + O(13^7))*t^2 + (13 + O(13^8))*t + (O(13^7))
sage: d = R([K(1,4), K(2, 6), K(1, 5)]); d
(1 + O(13^5))*t^2 + (2 + O(13^6))*t + (1 + O(13^4))
sage: e = c * d; e
(O(13^7))*t^6 + (O(13^7))*t^5 + (2*13 + O(13^6))*t^4 + (5*13 + O(13^6))*t^3 + (4*13 + O(13^5))*t^2 + (13 + O(13^5))*t + (O(13^7))
sage: e.list()
[O(13^7),
13 + O(13^5),
4*13 + O(13^5),
5*13 + O(13^6),
2*13 + O(13^6),
O(13^7),
O(13^7)]
"""
self._normalize()
right._normalize()
zzpoly = self._poly * right._poly
if len(self._relprecs) == 0 or len(right._relprecs) == 0:
return self.parent()(0)
n = Integer(len(self._relprecs) + len(right._relprecs) - 1).exact_log(2) + 1
precpoly1 = self._getprecpoly(n) * right._getvalpoly(n)
precpoly2 = self._getvalpoly(n) * right._getprecpoly(n)
# These two will be the same length
tn = Integer(1) << n
preclist = [min(a.valuation(tn), b.valuation(tn)) for (a, b) in zip(precpoly1.list(), precpoly2.list())]
answer = Polynomial_padic_capped_relative_dense(self.parent(), (zzpoly, self._valbase + right._valbase, preclist, False, None, None), construct = True)
answer._reduce_poly()
return answer
def _lmul_(self, right):
return self._rmul_(right)
def _rmul_(self, left):
"""
Returns self multiplied by a constant
EXAMPLES::
sage: K = Qp(13,7)
sage: R.<t> = K[]
sage: a = t^4 + K(13,5)*t^2 + 13
sage: K(13,7) * a
(13 + O(13^7))*t^4 + (13^2 + O(13^6))*t^2 + (13^2 + O(13^8))
"""
return None
# The code below has never been tested and is somehow subtly broken.
if self._valaddeds is None:
self._comp_valaddeds()
if left != 0:
val, unit = left.val_unit()
left_rprec = left.precision_relative()
relprecs = [min(left_rprec + self._valaddeds[i], self._relprecs[i]) for i in range(len(self._relprecs))]
elif left._is_exact_zero():
return Polynomial_padic_capped_relative_dense(self.parent(), [])
else:
return Polynomial_padic_capped_relative_dense(self.parent(), (self._poly.parent()(0), self._valbase + left.valuation(), self._valaddeds, False, self._valaddeds, None), construct = True)
return Polynomial_padic_capped_relative_dense(self.parent(), (self._poly._rmul_(unit), self._valbase + val, relprecs, False, self._valaddeds, None), construct = True)
def _neg_(self):
"""
Returns the negation of self.