本文整理汇总了Python中sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing.rescale方法的典型用法代码示例。如果您正苦于以下问题:Python PolynomialRing.rescale方法的具体用法?Python PolynomialRing.rescale怎么用?Python PolynomialRing.rescale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing
的用法示例。
在下文中一共展示了PolynomialRing.rescale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 rescale [as 别名]
#.........这里部分代码省略.........
sage: K = Qp(13,7)
sage: R.<t> = K[]
sage: f = t^3 + 4*t; f
(1 + O(13^7))*t^3 + (4 + O(13^7))*t
sage: f.reverse()
(4 + O(13^7))*t^2 + (1 + O(13^7))
sage: f.reverse(3)
(4 + O(13^7))*t^2 + (1 + O(13^7))
sage: f.reverse(2)
(4 + O(13^7))*t
sage: f.reverse(4)
(4 + O(13^7))*t^3 + (1 + O(13^7))*t
sage: f.reverse(6)
(4 + O(13^7))*t^5 + (1 + O(13^7))*t^3
"""
if n is None:
n = self._poly.degree()
zzlist = self._poly.list()[:(n+1)] + [0] * (n - self._poly.degree())
zzlist.reverse()
relprec = self._relprecs[:(n+1)] + [infinity] * (n - self.prec_degree())
relprec.reverse()
if self._valaddeds is None:
valadded = None
else:
valadded = self._valaddeds[:(n+1)] + [infinity] * (n - self.prec_degree())
valadded.reverse()
if self._list is None:
L = None
else:
L = self._list[:(n+1)] + [self.base_ring()(0)] * (n - self.prec_degree())
L.reverse()
return Polynomial_padic_capped_relative_dense(self.parent(), (self._poly.parent()(zzlist), self._valbase, relprec, self._normalized, valadded, L), construct = True)
def rescale(self, a):
r"""
Return f(a*X)
NOTE: Need to write this function for integer polynomials before this works.
EXAMPLES::
sage: K = Zp(13, 5)
sage: R.<t> = K[]
sage: f = t^3 + K(13, 3) * t
sage: f.rescale(2) # not implemented
"""
negval = False
try:
a = self.base_ring()(a)
except ValueError as msg:
if msg == "element has negative valuation.":
negval = True
else:
raise ValueError(msg)
if negval:
return self.parent().base_extend(self.base_ring().fraction_field())(self).rescale(a)
if self.base_ring().is_field() and a.valuation() < 0:
D = self.prec_degree()
return a**D * self.reverse(D).rescale(~a).reverse(D)
aval = a.valuation()
arprec = a.precision_relative()
if self._valaddeds is None:
self._comp_valaddeds()
valadded = [self._valaddeds[i] + aval * i for i in range(len(self._valaddeds))]
relprec = [infinity if (self._relprecs[i] is infinity) else (min(self._relprecs[i] - self._valaddeds[i], arprec) + aval * i + self._valaddeds[i]) for i in range(len(self._relprecs))]
relprec[0] = self._relprecs[0]