当前位置: 首页>>代码示例>>Python>>正文


Python Integer.gcd方法代码示例

本文整理汇总了Python中sage.rings.all.Integer.gcd方法的典型用法代码示例。如果您正苦于以下问题:Python Integer.gcd方法的具体用法?Python Integer.gcd怎么用?Python Integer.gcd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sage.rings.all.Integer的用法示例。


在下文中一共展示了Integer.gcd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _semistable_reducible_primes

# 需要导入模块: from sage.rings.all import Integer [as 别名]
# 或者: from sage.rings.all.Integer import gcd [as 别名]
def _semistable_reducible_primes(E, verbose=False):
    r"""Find a list containing all semistable primes l unramified in K/QQ
    for which the Galois image for E could be reducible.

    INPUT:

    - ``E`` - EllipticCurve - over a number field.

    OUTPUT:

    A list of primes, which contains all primes `l` unramified in
    `K/\mathbb{QQ}`, such that `E` is semistable at all primes lying
    over `l`, and the Galois image at `l` is reducible. If `E` has CM
    defined over its ground field, a ``ValueError`` is raised.

    EXAMPLES::

        sage: E = EllipticCurve([0, -1, 1, -10, -20]) # X_0(11)
        sage: 5 in sage.schemes.elliptic_curves.gal_reps_number_field._semistable_reducible_primes(E)
        True

    This example, over a quintic field with Galois group `S_5`, took a
    very long time before :trac:`22343`::

        sage: K.<a> = NumberField(x^5 - 6*x^3 + 8*x - 1)
        sage: E = EllipticCurve(K, [a^3 - 2*a, a^4 - 2*a^3 - 4*a^2 + 6*a + 1, a + 1, -a^3 + a + 1, -a])
        sage: from sage.schemes.elliptic_curves.gal_reps_number_field import _semistable_reducible_primes
        sage: _semistable_reducible_primes(E)
        [2, 5, 53, 1117]
    """
    if verbose: print("In _semistable_reducible_primes with E={}".format(E.ainvs()))
    K = E.base_field()
    d = K.degree()

    deg_one_primes = deg_one_primes_iter(K, principal_only=True)

    bad_primes = set([]) # This will store the output.

    # We find two primes (of distinct residue characteristics) which are
    # of degree 1, unramified in K/Q, and at which E has good reduction.
    # Each of these primes will give us a nontrivial divisibility constraint
    # on the exceptional primes l. For both of these primes P, we precompute
    # a generator and the characteristic polynomial of Frob_P^12.

    precomp = []
    last_p = 0 # The residue characteristic of the most recent prime.

    while len(precomp) < 2:
        P = next(deg_one_primes)
        p = P.norm()
        if p != last_p and (d==1 or P.ramification_index() == 1) and E.has_good_reduction(P):
            precomp.append(P)
            last_p = p

    Px, Py = precomp
    x, y = [P.gens_reduced()[0] for P in precomp]
    EmodPx = E.reduction(Px) if d>1 else E.reduction(x)
    EmodPy = E.reduction(Py) if d>1 else E.reduction(y)
    fxpol = EmodPx.frobenius_polynomial()
    fypol = EmodPy.frobenius_polynomial()
    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:

#.........这里部分代码省略.........
开发者ID:mcognetta,项目名称:sage,代码行数:103,代码来源:gal_reps_number_field.py


注:本文中的sage.rings.all.Integer.gcd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。