本文整理汇总了Python中sage.rings.all.Integer.isqrt方法的典型用法代码示例。如果您正苦于以下问题:Python Integer.isqrt方法的具体用法?Python Integer.isqrt怎么用?Python Integer.isqrt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.all.Integer
的用法示例。
在下文中一共展示了Integer.isqrt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _semistable_reducible_primes
# 需要导入模块: from sage.rings.all import Integer [as 别名]
# 或者: from sage.rings.all.Integer import isqrt [as 别名]
#.........这里部分代码省略.........
fx12pol = fxpol.adams_operator(12) # roots are 12th powers of those of fxpol
fy12pol = fypol.adams_operator(12)
px = x.norm() if d>1 else x
py = y.norm() if d>1 else x
Zx = fxpol.parent()
xpol = x.charpoly() if d>1 else Zx([-x,1])
ypol = y.charpoly() if d>1 else Zx([-y,1])
if verbose: print("Finished precomp, x={} (p={}), y={} (p={})".format(x,px,y,py))
for w in range(1+d/2):
if verbose: print("w = {}".format(w))
gx = xpol.symmetric_power(w).adams_operator(12).resultant(fx12pol)
gy = ypol.symmetric_power(w).adams_operator(12).resultant(fy12pol)
if verbose: print("computed gx and gy")
gxn = Integer(gx.absolute_norm()) if d>1 else gx
gyn = Integer(gy.absolute_norm()) if d>1 else gy
gxyn = gxn.gcd(gyn)
if gxyn:
xprimes = gxyn.prime_factors()
if verbose: print("adding prime factors {} of {} to {}".format(xprimes, gxyn, sorted(bad_primes)))
bad_primes.update(xprimes)
if verbose: print("...done, bad_primes now {}".format(sorted(bad_primes)))
continue
else:
if verbose: print("gx and gy both 0!")
## It is possible that our curve has CM. ##
# Our character must be of the form Nm^K_F for an imaginary
# quadratic subfield F of K (which is the CM field if E has CM).
# Note that this can only happen when d is even, w=d/2, and K
# contains (or the Galois closure of K contains?) the
# imaginary quadratic field F = Q(sqrt(a)) which is the
# splitting field of both fx12pol and fy12pol. We compute a
# and relativise K over F:
a = fx12pol.discriminant().squarefree_part()
# Construct a field isomorphic to K but a relative extension over QQ(sqrt(a)).
# See #19229: the names given here, which are not used, should
# not be the name of the generator of the base field.
rootsa = K(a).sqrt(all=True) # otherwise if a is not a square the
# returned result is in the symbolic ring!
try:
roota = rootsa[0]
except IndexError:
raise RuntimeError("error in _semistable_reducible_primes: K={} does not contain sqrt({})".format(K,a))
K_rel = K.relativize(roota, ['name1','name2'])
iso = K_rel.structure()[1] # an isomorphism from K to K_rel
E_rel = E.change_ring(iso) # same as E but over K_rel
## We try again to find a nontrivial divisibility condition. ##
div = 0
patience = 5 * K.absolute_degree()
# Number of Frobenius elements to check before suspecting that E
# has CM and computing the set of CM j-invariants of K to check.
# TODO: Is this the best value for this parameter?
while div==0 and patience>0:
P = next(deg_one_primes) # a prime of K not K_rel
while E.has_bad_reduction(P):
P = next(deg_one_primes)
if verbose: print("trying P = {}...".format(P))
EmodP = E.reduction(P)
fpol = EmodP.frobenius_polynomial()
if verbose: print("...good reduction, frobenius poly = {}".format(fpol))
x = iso(P.gens_reduced()[0]).relative_norm()
xpol = x.charpoly().adams_operator(12)
div2 = Integer(xpol.resultant(fpol.adams_operator(12)) // x.norm()**12)
if div2:
div = div2.isqrt()
assert div2==div**2
if verbose: print("...div = {}".format(div))
else:
if verbose: print("...div = 0, continuing")
patience -= 1
if patience == 0:
# We suspect that E has CM, so we check:
if E.has_cm():
raise ValueError("In _semistable_reducible_primes, the curve E should not have CM.")
assert div != 0
# We found our divisibility constraint.
xprimes = div.prime_factors()
if verbose: print("...adding prime factors {} of {} to {}...".format(xprimes,div, sorted(bad_primes)))
bad_primes.update(xprimes)
if verbose: print("...done, bad_primes now {}".format(sorted(bad_primes)))
L = sorted(bad_primes)
return L