本文整理汇总了Python中sage.all.PolynomialRing.degree方法的典型用法代码示例。如果您正苦于以下问题:Python PolynomialRing.degree方法的具体用法?Python PolynomialRing.degree怎么用?Python PolynomialRing.degree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.all.PolynomialRing
的用法示例。
在下文中一共展示了PolynomialRing.degree方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pol_string_to_list
# 需要导入模块: from sage.all import PolynomialRing [as 别名]
# 或者: from sage.all.PolynomialRing import degree [as 别名]
def pol_string_to_list(pol, deg=None, var=None):
if var is None:
from lmfdb.hilbert_modular_forms.hilbert_field import findvar
var = findvar(pol)
if not var:
var = 'a'
pol = PolynomialRing(QQ, var)(str(pol))
if deg is None:
fill = 0
else:
fill = deg - pol.degree() - 1
return [str(c) for c in pol.coefficients(sparse=False)] + ['0']*fill
示例2: poly_to_field_label
# 需要导入模块: from sage.all import PolynomialRing [as 别名]
# 或者: from sage.all.PolynomialRing import degree [as 别名]
def poly_to_field_label(pol):
try:
pol = PolynomialRing(QQ, 'x')(str(pol))
pol *= pol.denominator()
R = pol.parent()
pol = R(pari(pol).polredabs())
except:
return None
coeffs = list2string([int(c) for c in pol.coeffs()])
d = int(pol.degree())
query = {'coeffs': coeffs}
C = base.getDBConnection()
one = C.numberfields.fields.find_one(query)
if one:
return one['label']
return None
示例3: check_roots_are_roots
# 需要导入模块: from sage.all import PolynomialRing [as 别名]
# 或者: from sage.all.PolynomialRing import degree [as 别名]
def check_roots_are_roots(self, rec, verbose=False):
"""
check that embedding_root_real, and embedding_root_image approximate a root of field_poly
"""
poly = PolynomialRing(ZZ, "x")(rec['field_poly'])
dpoly = poly.derivative()
dbroots = db.mf_hecke_cc.search({'hecke_orbit_code': rec['hecke_orbit_code']}, ["embedding_root_real", "embedding_root_imag"])
dbroots = [CCC(root["embedding_root_real"], root["embedding_root_imag"]) for root in dbroots]
if len(dbroots) != poly.degree():
if verbose:
print "Wrong number of roots"
return False
for r in dbroots:
# f is irreducible, so all roots are simple and checking relative error is the way to go
if poly(r)/dpoly(r) > 1e-11:
# It's still possible that the roots are correct; it could just be a problem of numerical instability
print r, poly(r)/dpoly(r)
break
else:
return True
roots = poly.roots(CCC, multiplicities=False)
# greedily match. The degrees are all at most 20, so it's okay to use a quadratic algorithm
while len(roots) > 0:
best_dist = infinity
r = roots[0]
for i, s in enumerate(dbroots):
dist = abs(r-s)
if dist < best_dist:
best_dist, best_i = dist, i
# The dim 1 case where poly=x is handled correctly in the earlier loop, so r != 0.
if best_dist/abs(r) > 1e-13:
if verbose:
print "Roots mismatch", sorted(roots), sorted(dbroots)
return False
roots.pop(0)
dbroots.pop(best_i)
return True
示例4: field
# 需要导入模块: from sage.all import PolynomialRing [as 别名]
# 或者: from sage.all.PolynomialRing import degree [as 别名]
def field(self):
if not self.__field:
f = PolynomialRing(ZZ,name='x')(str(self.__field_poly))
self.__field = QQ if f.degree() == 1 else NumberField(f,'a')
return self.__field