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


Python EllipticCurve.integral_model方法代码示例

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


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

示例1: simon_two_descent

# 需要导入模块: from constructor import EllipticCurve [as 别名]
# 或者: from constructor.EllipticCurve import integral_model [as 别名]
def simon_two_descent(E, verbose=0, lim1=5, lim3=50, limtriv=10, maxprob=20, limbigprime=30):
    """
    Interface to Simon's gp script for two-descent.

    .. NOTE::

       Users should instead run E.simon_two_descent()

    EXAMPLES::

        sage: import sage.schemes.elliptic_curves.gp_simon
        sage: E=EllipticCurve('389a1')
        sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
        [2, 2, [(1 : 0 : 1), (-11/9 : -55/27 : 1)]]
        sage: E.simon_two_descent()
        (2, 2, [(1 : 0 : 1), (-11/9 : -55/27 : 1)])

    TESTS::

        sage: E = EllipticCurve('37a1').change_ring(QuadraticField(-11,'x'))
        sage: E.simon_two_descent()
        (1, 1, [(-1 : 0 : 1)])

    """
    init()

    current_randstate().set_seed_gp(gp)

    K = E.base_ring()
    K_orig = K
    # The following is to correct the bug at \#5204: the gp script
    # fails when K is a number field whose generator is called 'x'.
    if not K is QQ:
        K = K.change_names('a')
    E_orig = E
    E = EllipticCurve(K,[K(list(a)) for a in E.ainvs()])
    F = E.integral_model()

    if K != QQ:
        # Simon's program requires that this name be y.
        with localvars(K.polynomial().parent(), 'y'):
            gp.eval("K = bnfinit(%s);" % K.polynomial())
            if verbose >= 2:
                print "K = bnfinit(%s);" % K.polynomial()
        gp.eval("%s = Mod(y,K.pol);" % K.gen())
        if verbose >= 2:
            print "%s = Mod(y,K.pol);" % K.gen()

    if K == QQ:
        cmd = 'ellrank([%s,%s,%s,%s,%s]);' % F.ainvs()
    else:
        cmd = 'bnfellrank(K, [%s,%s,%s,%s,%s]);' % F.ainvs()

    gp('DEBUGLEVEL_ell=%s; LIM1=%s; LIM3=%s; LIMTRIV=%s; MAXPROB=%s; LIMBIGPRIME=%s;'%(
        verbose, lim1, lim3, limtriv, maxprob, limbigprime))

    if verbose >= 2:
        print cmd
    s = gp.eval('ans=%s;'%cmd)
    if s.find("***") != -1:
        raise RuntimeError, "\n%s\nAn error occurred while running Simon's 2-descent program"%s
    if verbose > 0:
        print s
    v = gp.eval('ans')
    if v=='ans': # then the call to ellrank() or bnfellrank() failed
        return 'fail'
    if verbose >= 2:
        print "v = ", v
    # pari represents field elements as Mod(poly, defining-poly)
    # so this function will return the respective elements of K
    def _gp_mod(*args):
        return args[0]
    ans = sage_eval(v, {'Mod': _gp_mod, 'y': K.gen(0)})
    inv_transform = F.isomorphism_to(E)
    ans[2] = [inv_transform(F(P)) for P in ans[2]]
    ans[2] = [E_orig([K_orig(list(c)) for c in list(P)]) for P in ans[2]]
    return ans
开发者ID:sageb0t,项目名称:testsage,代码行数:79,代码来源:gp_simon.py


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