Changeset 7681:04ba6e30689b


Ignore:
Timestamp:
11/14/07 07:13:48 (6 years ago)
Author:
Robert Bradshaw <robertwb@…>
Branch:
default
Message:

Integrate new simon two descent code

Location:
sage
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sage/categories/morphism.pyx

    r6782 r7681  
    213213    def __pow__(self, n, dummy): 
    214214        return self 
     215         
     216    def __invert__(self): 
     217        return self 
    215218             
    216219 
  • sage/schemes/elliptic_curves/ell_generic.py

    r7058 r7681  
    4444import sage.modular.modform as modform 
    4545import sage.functions.transcendental as transcendental 
     46 
     47from sage.categories.morphism import IdentityMorphism 
     48from sage.categories.homset import Hom 
     49from sage.rings.arith import lcm 
    4650 
    4751# Schemes 
     
    13041308        return constructor.EllipticCurve([-c4/(2**4*3), -c6/(2**5*3**3)]) 
    13051309         
     1310    def integral_model(self): 
     1311        denom = lcm([a.denominator() for a in self.ainvs()]) 
     1312        if denom != 1: 
     1313            raise NotImplementedError, "model must be integral for now" 
     1314        else: 
     1315            parent = self(0).parent() 
     1316            return self, IdentityMorphism(Hom(parent, parent)) 
     1317 
    13061318     
    13071319 
  • sage/schemes/elliptic_curves/ell_number_field.py

    r6767 r7681  
    132132        #if self.torsion_order() % 2 == 0: 
    133133        #    raise ArithmeticError, "curve must not have rational 2-torsion\nThe *only* reason for this is that I haven't finished implementing the wrapper\nin this case.  It wouldn't be too difficult.\nPerhaps you could do it?!  Email me (wstein@gmail.com)." 
    134         F = self.integral_weierstrass_model() 
    135         a1,a2,a3,a4,a6 = F.a_invariants() 
     134        # F = self.integral_weierstrass_model() 
     135        # a1,a2,a3,a4,a6 = F.a_invariants() 
    136136        x = PolynomialRing(self.base_ring(), 'x').gen(0) 
    137         t = simon_two_descent(a2,a4,a6,  
     137        t = simon_two_descent(self, 
    138138                              verbose=verbose, lim1=lim1, lim3=lim3, limtriv=limtriv, 
    139139                              maxprob=maxprob, limbigprime=limbigprime) 
    140140        prob_rank = Integer(t[0]) 
    141141        two_selmer_rank = Integer(t[1]) 
    142         prob_gens = [F(P) for P in t[2]] 
     142        prob_gens = [self(P) for P in t[2]] 
    143143        return prob_rank, two_selmer_rank, prob_gens 
    144144                 
  • sage/schemes/elliptic_curves/ell_rational_field.py

    r7000 r7681  
    858858            (8, 8) 
    859859        """ 
    860         if self.torsion_order() % 2 == 0: 
    861             raise ArithmeticError, "curve must not have rational 2-torsion\nThe *only* reason for this is that I haven't finished implementing the wrapper\nin this case.  It wouldn't be too difficult.\nPerhaps you could do it?!  Email me (wstein@gmail.com)." 
    862         F = self.integral_weierstrass_model() 
    863         a1,a2,a3,a4,a6 = F.a_invariants() 
    864         t = simon_two_descent(a2,a4,a6, verbose=verbose, lim1=lim1, lim3=lim3, limtriv=limtriv, 
     860        t = simon_two_descent(self, verbose=verbose, lim1=lim1, lim3=lim3, limtriv=limtriv, 
    865861                              maxprob=maxprob, limbigprime=limbigprime) 
    866862        prob_rank = rings.Integer(t[0]) 
    867863        two_selmer_rank = rings.Integer(t[1]) 
    868         prob_gens = [F(P) for P in t[2]] 
     864        prob_gens = [self(P) for P in t[2]] 
    869865        return prob_rank, two_selmer_rank, prob_gens 
    870866 
  • sage/schemes/elliptic_curves/gp_simon.py

    r6066 r7681  
    2828 
    2929gp = None 
    30 def init(K, two_torsion): 
     30def init(): 
    3131    global gp 
    3232    if gp is None: 
    3333        gp = Gp(script_subdirectory='simon') 
    3434        gp.read("ell.gp") 
    35         if K == QQ and two_torsion == 1: 
    36             gp.read("ellQ.gp") 
     35        gp.read("ellQ.gp") 
    3736        gp.read("qfsolve.gp") 
    3837        gp.read("resultant3.gp") 
    3938 
    4039 
    41 def simon_two_descent(A, B, C, verbose=0, lim1=5, lim3=50, limtriv=10, maxprob=20, limbigprime=30): 
     40def simon_two_descent(E, verbose=0, lim1=5, lim3=50, limtriv=10, maxprob=20, limbigprime=30): 
    4241 
    43     K = A.parent() 
    44     x = PolynomialRing(K, 'x').gen(0) 
    45     f = x**3 + A*x**2 + B*x + C 
    46     factors = f.factor() 
    47     two_torsion = 1 << (len(factors) - 1) 
     42    init() 
     43    K = E.base_ring() 
     44    F, transform = E.integral_model() 
    4845     
    49     init(K, two_torsion) 
    50     shift = 0 
    51      
    52     if K == QQ: 
    53         gp.eval("K = bnfinit(y-1)") # TODO: Is there a better way to get QQ? 
    54     else: 
     46    if K != QQ: 
    5547        # Simon's program requires that this name be y.  
    5648        with localvars(K.polynomial().parent(), 'y'): 
     
    6254            print "%s = Mod(y,K.pol);" % K.gen() 
    6355     
    64     if two_torsion == 1: 
    65         if K == QQ: 
    66             cmd = 'main(%s,%s,%s);'%(A,B,C) 
    67         else: 
    68             # Simon's program requires that the coefficients do NOT all lie in a subfield of K 
    69             if A.minpoly().degree() != K.degree(): 
    70                 shift = K.gen() 
    71                 shifted = f(x+shift) 
    72                 C, B, A, _ = shifted 
    73             cmd = 'main(K, %s,%s,%s);'%(A,B,C) 
     56    if K == QQ: 
     57        cmd = 'ellrank([%s,%s,%s,%s,%s]);' % tuple(F.ainvs()) 
     58    else: 
     59        cmd = 'bnfellrank(K, [%s,%s,%s,%s,%s]);' % tuple(F.ainvs()) 
    7460             
    75     elif two_torsion == 2: 
    76         if C != 0: 
    77             # If E[2] = Z/2Z, it must be of the form y^2 = x^3 + Ax^2 + Bx 
    78             shift = -factors[0][0][0] 
    79             shifted = f(x+shift) 
    80             C, B, A, _ = shifted 
    81         cmd = 'main2(K, [0, %s, 0, %s, 0])'%(A,B) 
    82  
    83     else:  # two_torsion == 4: 
    84         cmd = 'complete(K, %s,%s,%s)'%(factors[0][0][0], factors[1][0][0], factors[2][0][0]) 
    85  
    8661    gp('DEBUGLEVEL=%s; LIM1=%s; LIM3=%s; LIMTRIV=%s; MAXPROB=%s; LIMBIGPRIME=%s;'%( 
    8762        verbose, lim1, lim3, limtriv, maxprob, limbigprime)) 
     63 
    8864    if verbose >= 2: 
    8965        print cmd 
     
    10177        return args[0] 
    10278    ans = sage_eval(v, {'Mod': gp_mod, 'y': K.gen(0)}) 
    103     if two_torsion != 1: 
    104         # selmer group rank and generating points not 
    105         # returned for non-trivial 2-torsion 
    106         ans = [ans, -1, []] 
    107     if shift: 
    108         # Undo the x -> x+a translation above 
    109         ans[2] = [[P[0]+shift, P[1]] for P in ans[2]] 
     79    inv_transform = ~transform 
     80    ans[2] = [inv_transform(F(P)) for P in ans[2]] 
    11081    return ans 
    11182 
Note: See TracChangeset for help on using the changeset viewer.