Ticket #3961: sage-trac3926.patch

File sage-trac3926.patch, 4.2 kB (added by cremona, 4 months ago)
  • a/sage/schemes/elliptic_curves/ell_finite_field.py

    old new  
    10141014            sage: for p in prime_range(10000):           #long time (~20s) 
    10151015            ...       if p != 389: 
    10161016            ...           G=E.change_ring(GF(p)).abelian_group() 
     1017 
     1018        This tests that the bug reported in trac \#3926 has been fixed:     
     1019            sage: K.<i> = QuadraticField(-1) 
     1020            sage: OK = K.ring_of_integers()    
     1021            sage: P=K.factor(10007)[0][0] 
     1022            sage: OKmodP = OK.residue_field(P) 
     1023            sage: E = EllipticCurve([0,0,0,i,i+3]) 
     1024            sage: Emod = E.change_ring(OKmodP); Emod 
     1025            Elliptic Curve defined by y^2  = x^3 + ibar*x + (ibar+3) over Residue field in ibar of Fractional ideal (10007)               
     1026            sage: Emod.abelian_group() #random generators 
     1027            (Multiplicative Abelian Group isomorphic to C50067594 x C2, 
     1028            ((3152*ibar + 7679 : 7330*ibar + 7913 : 1), (8466*ibar + 1770 : 0 : 1))) 
    10171029        """ 
    10181030        if not debug: 
    10191031            # if we're in debug mode, always recalculate 
     
    11201132                    P1a = n1a*P1    # has order = n1b 
    11211133                if debug: print "n1a=",n1a 
    11221134                a = None 
    1123                 for m in (N//n1).divisors(): 
     1135                for m in n1b.divisors(): 
    11241136                    try: 
    11251137                        a = generic.bsgs(m*P1a,m*Q,(0,(n1b//m)-1),operation='+') 
    11261138                        break 
     
    11391151                        n2=m 
    11401152                        if debug: 
    11411153                            print "Adding second generator ",P2," of order ",n2 
    1142                             print "Group order now ",n1*n2,"=",n1,"*",n2 
     1154                            print "Subgroup order now ",n1*n2,"=",n1,"*",n2 
    11431155                    else:     # we must merge P2 and Q: 
    11441156                        oldn2=n2 # holds old value 
    11451157                        P2,n2=generic.merge_points((P2,n2),(Q,m),operation='+'); 
     
    11491161                            if n2>oldn2: 
    11501162                                print "Replacing second generator by ",P2, 
    11511163                                print " of order ",n2, "  gaining index ",n2//oldn2 
    1152                                 print "Group order now ",n1*n2,"=",n1,"*",n2 
     1164                                print "Subgroup order now ",n1*n2,"=",n1,"*",n2 
    11531165            elif not Q1.is_zero(): # Q1 nonzero: n1 will increase 
    11541166                if debug:  print "Case 1: n1 may increase" 
    11551167                oldn1=n1 
     
    11651177                if debug: 
    11661178                    print "Replacing first  generator by ",P1," of order ", 
    11671179                    print n1,", gaining index ",n1//oldn1 
    1168                     print "Group order now ",n1*n2,"=",n1,"*",n2 
     1180                    print "Subgroup order now ",n1*n2,"=",n1,"*",n2 
     1181 
     1182                # If we did not yet know the group order, we may now be 
     1183                # able to determine it 
     1184                if not group_order_known: 
     1185                    M = n1*n2  # group order is a multiple of this 
     1186                    c1 = (upper/M).floor() 
     1187                    if c1 == (lower/M).ceil(): 
     1188                        group_order_known = True 
     1189                        lower = upper = N = c1*M 
     1190                        if debug: 
     1191                            print "Group order now determined to be ",N 
     1192 
    11691193                # Now replace P2 by a point of order n2 s.t. it and 
    11701194                # (n1//n2)*P1 are still a basis for n2-torsion: 
    11711195                if n2>1: 
     
    12041228                        raise ValueError 
    12051229                print "Generators: P1 = ",P1," of order ",n1, 
    12061230                print ", P2 = ",P2," of order ",n2 
    1207                 print "Group order now ",n1*n2,"=",n1,"*",n2 
     1231                print "Subgroup order is now ",n1*n2,"=",n1,"*",n2 
    12081232 
    12091233        # Finished: record group order, structure and generators 
    12101234