Changeset 5447:cd60620ddfe5


Ignore:
Timestamp:
06/05/07 01:49:06 (6 years ago)
Author:
David Kohel <kohel@…>
Branch:
default
Children:
5448:a711eb87b846, 5449:bb432d7a85b0
Message:

Fixes to left multiplication and coercion of 0 in Jacobians and point sets.

Location:
sage/schemes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sage/schemes/generic/scheme.py

    r4852 r5447  
    7676        """ 
    7777        raise NotImplementedError 
    78  
    7978 
    8079    def __call__(self, *args): 
  • sage/schemes/hyperelliptic_curves/jacobian_generic.py

    r4851 r5447  
    1818 
    1919class HyperellipticJacobian_generic(Jacobian_generic): 
    20     def __call__(self, *args, **kwds): 
    21         """ 
    22         EXAMPLES: 
    23             sage: FF = FiniteField(2003) 
    24             sage: R.<x> = PolynomialRing(FF) 
    25             sage: f = x**5 + 1184*x**3 + 1846*x**2 + 956*x + 560 
    26             sage: C = HyperellipticCurve(f) 
    27             sage: J = Jacobian(C) 
    28             sage: a = x**2 + 376*x + 245; b = 1015*x + 1368 
    29             sage: X = J(FF) 
    30             sage: D = X([a,b]) 
    31             sage: D 
    32             (x^2 + 376*x + 245, y + 988*x + 635) 
    33             sage: J(0) 
    34             (1) 
    35             sage: D == J([a,b]) 
    36             True 
    37             sage: D == D + J(0)  
    38             True 
    39         """      
    40         if len(args) == 1:  
    41             if is_Ring(args[0]): 
    42                 return jacobian_homset.JacobianHomset_divisor_classes(self, args[0]) 
    43             return jacobian_homset.JacobianHomset_divisor_classes(self, self.base_ring())(args[0]) 
    44         raise TypeError, "Arguments must be a coefficient ring or Mumford divisor." 
     20    """ 
     21    EXAMPLES: 
     22        sage: FF = FiniteField(2003) 
     23        sage: R.<x> = PolynomialRing(FF) 
     24        sage: f = x**5 + 1184*x**3 + 1846*x**2 + 956*x + 560 
     25        sage: C = HyperellipticCurve(f) 
     26        sage: J = C.jacobian() 
     27        sage: a = x**2 + 376*x + 245; b = 1015*x + 1368 
     28        sage: X = J(FF) 
     29        sage: D = X([a,b]) 
     30        sage: D 
     31        (x^2 + 376*x + 245, y + 988*x + 635) 
     32        sage: J(0) 
     33        (1) 
     34        sage: D == J([a,b]) 
     35        True 
     36        sage: D == D + J(0)  
     37        True 
     38 
     39    An more extended example, demonstrating arithmetic in J(QQ) and J(K) 
     40    for a number field K/QQ. 
     41 
     42        sage: P.<x> = PolynomialRing(QQ)                      
     43        sage: f = x^5 - x + 1; h = x                          
     44        sage: C = HyperellipticCurve(f,h,'u,v')               
     45        sage: C 
     46        Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 
     47        sage: PP = C.ambient_space()                          
     48        sage: PP 
     49        Projective Space of dimension 2 over Rational Field 
     50        sage: C.defining_polynomial()                         
     51        -x0^5 + x0*x1*x2^3 + x1^2*x2^3 + x0*x2^4 - x2^5 
     52        sage: C(QQ) 
     53        Set of Rational Points of Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 
     54        sage: K.<t> = NumberField(x^2-2)                      
     55        sage: C(K)     
     56        Set of Rational Points over Number Field in t with defining polynomial x^2 - 2 of Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 
     57        sage: P = C(QQ)(0,1,1); P                             
     58        (0 : 1 : 1)  
     59        sage: P == C(0,1,1)                                   
     60        True 
     61        sage: C(0,1,1).parent()                               
     62        Set of Rational Points of Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 
     63        sage: P1 = C(K)(P)                                    
     64        sage: P2 = C(K)([2,4*t-1,1])                          
     65        sage: P3 = C(K)([-1/2,1/8*(7*t+2),1])                 
     66        sage: P1, P2, P3                                      
     67        ((0 : 1 : 1), (2 : 4*t - 1 : 1), (-1/2 : 7/8*t + 1/4 : 1)) 
     68        sage: J = C.jacobian()                                
     69        sage: J        
     70        Jacobian of Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 
     71        sage: Q = J(QQ)(P); Q 
     72        (u, v + -1) 
     73        sage: for i in range(6): Q*i 
     74        (1) 
     75        (u, v + -1) 
     76        (u^2, v + u - 1) 
     77        (u^2, v + 1) 
     78        (u, v + 1) 
     79        (1) 
     80        sage: Q1 = J(K)(P1); print "%s -> %s"%( P1, Q1 )      
     81        (0 : 1 : 1) -> (u, v + -1) 
     82        sage: Q2 = J(K)(P2); print "%s -> %s"%( P2, Q2 ) 
     83        (2 : 4*t - 1 : 1) -> (u + -2, v + -4*t + 1) 
     84        sage: Q3 = J(K)(P3); print "%s -> %s"%( P3, Q3 ) 
     85        (-1/2 : 7/8*t + 1/4 : 1) -> (u + 1/2, v + -7/8*t - 1/4) 
     86        sage: R.<x> = PolynomialRing(K)                       
     87        sage: Q4 = J(K)([x^2-t,R(1)])                         
     88        sage: for i in range(4): Q4*i 
     89        (1) 
     90        (u^2 + -t, v + -1) 
     91        (u^2 + (-3/4*t - 9/16)*u + 1/2*t + 1/4, v + (-1/32*t - 57/64)*u + 1/2*t + 9/16) 
     92        (u^2 + (1352416/247009*t - 1636930/247009)*u + -1156544/247009*t + 1900544/247009, v + (-2326345442/122763473*t + 3233153137/122763473)*u + 2439343104/122763473*t - 3350862929/122763473) 
     93        sage: R2 = Q2*5; R2              
     94        (u^2 + (-3789465233/116983808)*u + -267915823/58491904, v + (-233827256513849/1789384327168*t + 1/2)*u + -15782925357447/894692163584*t) 
     95        sage: R3 = Q3*5; R3              
     96        (u^2 + 5663300808399913890623/14426454798950909645952*u + -26531814176395676231273/28852909597901819291904, v + (253155440321645614070860868199103/2450498420175733688903836378159104*t + 1/2)*u + 2427708505064902611513563431764311/4900996840351467377807672756318208*t) 
     97        sage: R4 = Q4*5; R4              
     98        (u^2 + (-3789465233/116983808)*u + -267915823/58491904, v + (233827256513849/1789384327168*t + 1/2)*u + 15782925357447/894692163584*t) 
     99        sage: # Thus we find the following identity: 
     100        sage: 5*Q2 + 5*Q4  
     101        (1) 
     102        sage: # Moreover the following relation holds in the 5-torsion subgroup: 
     103        sage: Q2 + Q4 == 2*Q1                      
     104        True 
     105    """      
    45106     
    46107    def dimension(self): 
    47108        return self.__curve.genus() 
     109 
     110    def point(self, mumford, check=True): 
     111        try:  
     112            return jacobian_homset.JacobianHomset_divisor_classes(self, self.base_ring())(mumford) 
     113        except AttributeError: 
     114            raise ValueError, "Arguments must determine a valid Mumford divisor." 
    48115 
    49116    def _homset_class(self, *args, **kwds): 
  • sage/schemes/hyperelliptic_curves/jacobian_homset.py

    r4851 r5447  
    2727 
    2828import sage.schemes.generic.spec as spec 
    29 from sage.rings.all import is_Polynomial, PolynomialRing, ZZ 
     29from sage.rings.all import is_Polynomial, PolynomialRing, Integer, ZZ 
    3030from sage.schemes.generic.homset import SchemeHomset_generic 
    3131from sage.schemes.generic.morphism import is_SchemeMorphism 
     
    6565            sage: J = C.jacobian() 
    6666            sage: Q = J(QQ)(P) 
    67             sage: for i in range(6): Q*i 
     67            sage: for i in range(6): i*Q 
    6868            (1) 
    6969            (u, v + -1) 
     
    7373            (1) 
    7474        """ 
    75         if P == 0: 
     75        if isinstance(P,(int,long,Integer)) and P == 0: 
    7676            R = PolynomialRing(self.value_ring(), 'x') 
    7777            return JacobianMorphism_divisor_class_field(self, (R(1),R(0))) 
     78        elif isinstance(P,(list,tuple)): 
     79            if len(P) == 1 and P[0] == 0: 
     80                R = PolynomialRing(self.value_ring(), 'x') 
     81                return JacobianMorphism_divisor_class_field(self, (R(1),R(0))) 
     82            elif len(P) == 2: 
     83                P1 = P[0]; P2 = P[1] 
     84                if is_Polynomial(P1) and is_Polynomial(P2): 
     85                    return JacobianMorphism_divisor_class_field(self, P) 
     86                if is_SchemeMorphism(P1) and is_SchemeMorphism(P2): 
     87                    return self(P1) - self(P2) 
     88            raise TypeError, "Argument P (= %s) must have length 2."%P 
    7889        elif isinstance(P,JacobianMorphism_divisor_class_field) and self == P.parent(): 
    7990            return P 
    80         elif isinstance(P,(list,tuple)): 
    81             if len(P) != 2: 
    82                 raise TypeError, "Argument P (= %s) must have length 2"%P 
    83             P1 = P[0]; P2 = P[1] 
    84             if is_Polynomial(P1) and is_Polynomial(P2): 
    85                 return JacobianMorphism_divisor_class_field(self, P) 
    86             if is_SchemeMorphism(P1) and is_SchemeMorphism(P2): 
    87                 return self(P1) - self(P2) 
    8891        elif is_SchemeMorphism(P): 
    8992            x0 = P[0]; y0 = P[1] 
  • sage/schemes/hyperelliptic_curves/jacobian_morphism.py

    r4851 r5447  
    125125        return "(%s, %s)"%(a(x), y - b(x)) 
    126126 
     127    def scheme(self): 
     128        return self.codomain() 
     129 
    127130    def list(self): 
    128131        return self.__polys 
     
    138141            D = cantor_composition(self.__polys,other.__polys,f,h,C.genus()) 
    139142        return JacobianMorphism_divisor_class_field(X, D, reduce=False, check=False) 
     143 
     144    def __cmp__(self, other): 
     145        if not isinstance(other, JacobianMorphism_divisor_class_field): 
     146            try: 
     147                other = self.parent()(other) 
     148            except TypeError: 
     149                return -1 
     150        return cmp(self.__polys, other.__polys) 
     151 
     152    def __nonzero__(self): 
     153        return self.__polys[0] != 1 
    140154 
    141155    def __sub__(self, other): 
     
    162176        X = self.parent() 
    163177        if n < 0: 
    164             return self * (-n) 
     178            return - self * (-n) 
    165179        elif n == 0: 
    166180            return self.parent()(0) 
    167181        elif n == 1: 
    168182            return self 
    169         D = self.__mul__(n//2) 
     183        elif n < 4: 
     184            D = self 
     185        else:        
     186            D = self.__mul__(n//2) 
    170187        if n % 2 == 0: 
    171188            return D + D 
     
    173190            return D + D + self 
    174191 
    175     def __nonzero__(self): 
    176         return self.__polys[0] != 1 
     192    def _rmul_(self, n): 
     193        return self.__mul__(n) 
    177194 
    178     def scheme(self): 
    179         return self.codomain() 
    180195 
     196 
Note: See TracChangeset for help on using the changeset viewer.