本文整理汇总了Python中sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing.valuation方法的典型用法代码示例。如果您正苦于以下问题:Python PolynomialRing.valuation方法的具体用法?Python PolynomialRing.valuation怎么用?Python PolynomialRing.valuation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing
的用法示例。
在下文中一共展示了PolynomialRing.valuation方法的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 valuation [as 别名]
class Polynomial_padic_capped_relative_dense(Polynomial_generic_domain):
def __init__(self, parent, x=None, check=True, is_gen=False, construct = False, absprec = infinity, relprec = infinity):
"""
TESTS:
sage: K = Qp(13,7)
sage: R.<t> = K[]
sage: R([K(13), K(1)])
(1 + O(13^7))*t + (13 + O(13^8))
sage: T.<t> = ZZ[]
sage: R(t + 2)
(1 + O(13^7))*t + (2 + O(13^7))
"""
Polynomial.__init__(self, parent, is_gen=is_gen)
parentbr = parent.base_ring()
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
if construct:
(self._poly, self._valbase, self._relprecs, self._normalized, self._valaddeds, self._list) = x #the last two of these may be None
return
elif is_gen:
self._poly = PolynomialRing(ZZ, parent.variable_name()).gen()
self._valbase = 0
self._valaddeds = [infinity, 0]
self._relprecs = [infinity, parentbr.precision_cap()]
self._normalized = True
self._list = None
return
#First we list the types that are turned into Polynomials
if isinstance(x, ZZX):
x = Polynomial_integer_dense(PolynomialRing(ZZ, parent.variable_name()), x, construct = True)
elif isinstance(x, fraction_field_element.FractionFieldElement) and \
x.denominator() == 1:
#Currently we ignore precision information in the denominator. This should be changed eventually
x = x.numerator()
#We now coerce various types into lists of coefficients. There are fast pathways for some types of polynomials
if isinstance(x, Polynomial):
if x.parent() is self.parent():
if not absprec is infinity or not relprec is infinity:
x._normalize()
self._poly = x._poly
self._valbase = x._valbase
self._valaddeds = x._valaddeds
self._relprecs = x._relprecs
self._normalized = x._normalized
self._list = x._list
if not absprec is infinity or not relprec is infinity:
self._adjust_prec_info(absprec, relprec)
return
elif x.base_ring() is ZZ:
self._poly = x
self._valbase = Integer(0)
p = parentbr.prime()
self._relprecs = [c.valuation(p) + parentbr.precision_cap() for c in x.list()]
self._comp_valaddeds()
self._normalized = len(self._valaddeds) == 0 or (min(self._valaddeds) == 0)
self._list = None
if not absprec is infinity or not relprec is infinity:
self._adjust_prec_info(absprec, relprec)
return
else:
x = [parentbr(a) for a in x.list()]
check = False
elif isinstance(x, dict):
zero = parentbr.zero_element()
n = max(x.keys())
v = [zero for _ in xrange(n + 1)]
for i, z in x.iteritems():
v[i] = z
x = v
elif isinstance(x, pari_gen):
x = [parentbr(w) for w in x.list()]
check = False
#The default behavior if we haven't already figured out what the type is is to assume it coerces into the base_ring as a constant polynomial
elif not isinstance(x, list):
x = [x] # constant polynomial
# In contrast to other polynomials, the zero element is not distinguished
# by having its list empty. Instead, it has list [0]
if not x:
x = [parentbr.zero_element()]
if check:
x = [parentbr(z) for z in x]
# Remove this -- for p-adics this is terrible, since it kills any non exact zero.
#if len(x) == 1 and not x[0]:
# x = []
self._list = x
self._valaddeds = [a.valuation() for a in x]
self._valbase = sage.rings.padics.misc.min(self._valaddeds)
if self._valbase is infinity:
self._valaddeds = []
self._relprecs = []
self._poly = PolynomialRing(ZZ, parent.variable_name())()
self._normalized = True
if not absprec is infinity or not relprec is infinity:
self._adjust_prec_info(absprec, relprec)
else:
self._valaddeds = [c - self._valbase for c in self._valaddeds]
#.........这里部分代码省略.........
示例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 valuation [as 别名]
class Polynomial_padic_capped_relative_dense(Polynomial_generic_domain, Polynomial_padic):
def __init__(self, parent, x=None, check=True, is_gen=False, construct = False, absprec = infinity, relprec = infinity):
"""
TESTS::
sage: K = Qp(13,7)
sage: R.<t> = K[]
sage: R([K(13), K(1)])
(1 + O(13^7))*t + (13 + O(13^8))
sage: T.<t> = ZZ[]
sage: R(t + 2)
(1 + O(13^7))*t + (2 + O(13^7))
Check that :trac:`13620` has been fixed::
sage: f = R.zero()
sage: R(f.dict())
0
"""
Polynomial.__init__(self, parent, is_gen=is_gen)
parentbr = parent.base_ring()
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
if construct:
(self._poly, self._valbase, self._relprecs, self._normalized, self._valaddeds, self._list) = x #the last two of these may be None
return
elif is_gen:
self._poly = PolynomialRing(ZZ, parent.variable_name()).gen()
self._valbase = 0
self._valaddeds = [infinity, 0]
self._relprecs = [infinity, parentbr.precision_cap()]
self._normalized = True
self._list = None
return
#First we list the types that are turned into Polynomials
if isinstance(x, ZZX):
x = Polynomial_integer_dense(PolynomialRing(ZZ, parent.variable_name()), x, construct = True)
elif isinstance(x, fraction_field_element.FractionFieldElement) and \
x.denominator() == 1:
#Currently we ignore precision information in the denominator. This should be changed eventually
x = x.numerator()
#We now coerce various types into lists of coefficients. There are fast pathways for some types of polynomials
if isinstance(x, Polynomial):
if x.parent() is self.parent():
if not absprec is infinity or not relprec is infinity:
x._normalize()
self._poly = x._poly
self._valbase = x._valbase
self._valaddeds = x._valaddeds
self._relprecs = x._relprecs
self._normalized = x._normalized
self._list = x._list
if not absprec is infinity or not relprec is infinity:
self._adjust_prec_info(absprec, relprec)
return
elif x.base_ring() is ZZ:
self._poly = x
self._valbase = Integer(0)
p = parentbr.prime()
self._relprecs = [c.valuation(p) + parentbr.precision_cap() for c in x.list()]
self._comp_valaddeds()
self._normalized = len(self._valaddeds) == 0 or (min(self._valaddeds) == 0)
self._list = None
if not absprec is infinity or not relprec is infinity:
self._adjust_prec_info(absprec, relprec)
return
else:
x = [parentbr(a) for a in x.list()]
check = False
elif isinstance(x, dict):
zero = parentbr.zero()
n = max(x.keys()) if x else 0
v = [zero for _ in xrange(n + 1)]
for i, z in x.iteritems():
v[i] = z
x = v
elif isinstance(x, pari_gen):
x = [parentbr(w) for w in x.list()]
check = False
#The default behavior if we haven't already figured out what the type is is to assume it coerces into the base_ring as a constant polynomial
elif not isinstance(x, list):
x = [x] # constant polynomial
# In contrast to other polynomials, the zero element is not distinguished
# by having its list empty. Instead, it has list [0]
if not x:
x = [parentbr.zero()]
if check:
x = [parentbr(z) for z in x]
# Remove this -- for p-adics this is terrible, since it kills any non exact zero.
#if len(x) == 1 and not x[0]:
# x = []
self._list = x
self._valaddeds = [a.valuation() for a in x]
self._valbase = sage.rings.padics.misc.min(self._valaddeds)
if self._valbase is infinity:
#.........这里部分代码省略.........