Ticket #9684: 9684_dirty_model.patch

File 9684_dirty_model.patch, 8.9 KB (added by arminstraub, 3 years ago)
  • sage/schemes/elliptic_curves/ell_local_data.py

    # HG changeset patch
    # User Armin Straub <math@arminstraub.com>
    # Date 1280898934 18000
    # Node ID ac4ded622575618fc79a6e4777f81d91b3641b6b
    # Parent  96585fa43e337918c0fab649ac2f8966a797cf61
    9684: Make use of _tidy_model() optional
    
    diff -r 96585fa43e33 -r ac4ded622575 sage/schemes/elliptic_curves/ell_local_data.py
    a b  
    262262            self._KS = KodairaSymbol(data[1].python()) 
    263263            self._cp = data[3].python() 
    264264            # We use a global minimal model since we can: 
    265             self._Emin = Eint.minimal_model() 
    266             self._val_disc = self._Emin.discriminant().valuation(p) 
     265            self._Emin_tidy = Eint.minimal_model() 
     266            self._val_disc = self._Emin_tidy.discriminant().valuation(p) 
    267267            if self._fp>0: 
    268268                self._reduction_type = Eint.ap(p) # = 0,-1 or +1 
    269269        else:         
     
    294294        red_type = "good" 
    295295        if not self._reduction_type is None: 
    296296            red_type = ["bad non-split multiplicative","bad additive","bad split multiplicative"][1+self._reduction_type] 
    297         return "Local data at %s:\nReduction type: %s\nLocal minimal model: %s\nMinimal discriminant valuation: %s\nConductor exponent: %s\nKodaira Symbol: %s\nTamagawa Number: %s"%(self._prime,red_type,self._Emin,self._val_disc,self._fp,self._KS,self._cp) 
     297        return "Local data at %s:\nReduction type: %s\nLocal minimal model: %s\nMinimal discriminant valuation: %s\nConductor exponent: %s\nKodaira Symbol: %s\nTamagawa Number: %s"%(self._prime,red_type,self.minimal_model(),self._val_disc,self._fp,self._KS,self._cp) 
    298298 
    299     def minimal_model(self): 
     299    def minimal_model(self, tidy=True): 
    300300        """ 
    301301        Return the (local) minimal model from this local reduction data. 
    302302 
     303        INPUT: 
     304 
     305        - ``tidy`` -- (default: True) if set to True the EC returned by Tate's algorithm will be  
     306          "tidied" as specified in _tidy_model() for curves over number fields. 
     307 
    303308        EXAMPLES:: 
    304309 
    305310            sage: from sage.schemes.elliptic_curves.ell_local_data import EllipticCurveLocalData 
     
    310315            Elliptic Curve defined by y^2 = x^3 + 1 over Rational Field 
    311316            sage: data.minimal_model() == E.local_minimal_model(2) 
    312317            True 
     318 
     319        To demonstrate the behaviour of the parameter ``tidy``:: 
     320 
     321            sage: K.<a> = NumberField(x^3+x+1) 
     322            sage: E = EllipticCurve(K, [0, 0, a, 0, 1]) 
     323            sage: E.local_data(K.ideal(a-1)).minimal_model() 
     324            Elliptic Curve defined by y^2 + a*y = x^3 + 1 over Number Field in a with defining polynomial x^3 + x + 1 
     325            sage: E.local_data(K.ideal(a-1)).minimal_model(tidy=False) 
     326            Elliptic Curve defined by y^2 + (a+2)*y = x^3 + 3*x^2 + 3*x + (-a+1) over Number Field in a with defining polynomial x^3 + x + 1 
     327 
     328            sage: E = EllipticCurve([2, 1, 0, -2, -1]) 
     329            sage: E.local_data(ZZ.ideal(2), algorithm="generic").minimal_model(tidy=False) 
     330            Elliptic Curve defined by y^2 + 2*x*y + 2*y = x^3 + x^2 - 4*x - 2 over Rational Field 
     331            sage: E.local_data(ZZ.ideal(2), algorithm="pari").minimal_model(tidy=False) 
     332            Traceback (most recent call last): 
     333            ... 
     334            ValueError: the argument tidy must not be False if algorithm=pari is used 
     335            sage: E.local_data(ZZ.ideal(2), algorithm="generic").minimal_model() 
     336            Elliptic Curve defined by y^2 = x^3 - x^2 - 3*x + 2 over Rational Field 
     337            sage: E.local_data(ZZ.ideal(2), algorithm="pari").minimal_model() 
     338            Elliptic Curve defined by y^2 = x^3 - x^2 - 3*x + 2 over Rational Field 
    313339        """ 
    314         return self._Emin 
     340        if tidy: 
     341            try: 
     342                return self._Emin_tidy 
     343            except AttributeError: 
     344                pass 
     345            self._Emin_tidy = self._Emin._tidy_model() 
     346            return self._Emin_tidy 
     347        else: 
     348            try: 
     349                return self._Emin 
     350            except AttributeError: 
     351                raise ValueError, "the argument tidy must not be False if algorithm=pari is used" 
    315352 
    316353    def prime(self): 
    317354        """ 
     
    938975                pie *= pi # now pie=pi^6 
    939976                a6 /= pie 
    940977                verbose("Non-minimal equation, dividing out...\nNew model is %s"%([a1, a2, a3, a4, a6]), t, 1) 
    941         C = C._tidy_model() 
    942978        return (C, p, val_disc, fp, KS, cp, split) 
    943979     
    944980     
  • sage/schemes/elliptic_curves/ell_number_field.py

    diff -r 96585fa43e33 -r ac4ded622575 sage/schemes/elliptic_curves/ell_number_field.py
    a b  
    439439        raise DeprecationWarning, "local_information is deprecated; use local_data instead" 
    440440        return self.local_data(P,proof) 
    441441 
    442     def local_data(self, P=None, proof = None): 
     442    def local_data(self, P=None, proof = None, algorithm="pari"): 
    443443        r""" 
    444444        Local data for this elliptic curve at the prime `P`. 
    445445 
     
    451451          (default controlled by global proof module).  Note that the 
    452452          proof module is number_field, not elliptic_curves, since the 
    453453          functions that actually need the flag are in number fields. 
     454 
     455        - ``algorithm`` (string, default: "pari") -- Ignored unless the 
     456          base field is `\QQ`.  If "pari", use the PARI C-library 
     457          ``ellglobalred`` implementation of Tate's algorithm over 
     458          `\QQ`. If "generic", use the general number field 
     459          implementation. 
    454460                      
    455461        OUTPUT: 
    456462 
     
    521527        from sage.schemes.elliptic_curves.ell_local_data import check_prime 
    522528        P = check_prime(self.base_field(),P) 
    523529 
    524         return self._get_local_data(P,proof)        
     530        return self._get_local_data(P,proof,algorithm)        
    525531 
    526     def _get_local_data(self, P, proof): 
     532    def _get_local_data(self, P, proof, algorithm="pari"): 
    527533        r""" 
    528534        Internal function to create data for this elliptic curve at the prime `P`. 
    529535         
     
    539545          (default controlled by global proof module).  Note that the 
    540546          proof module is number_field, not elliptic_curves, since the 
    541547          functions that actually need the flag are in number fields. 
     548 
     549        - ``algorithm`` (string, default: "pari") -- Ignored unless the 
     550          base field is `\QQ`.  If "pari", use the PARI C-library 
     551          ``ellglobalred`` implementation of Tate's algorithm over 
     552          `\QQ`. If "generic", use the general number field 
     553          implementation. 
    542554                      
    543555        EXAMPLES:: 
    544556 
     
    554566            Kodaira Symbol: I0 
    555567            Tamagawa Number: 1 
    556568             
    557         Verify that we cache based on the proof value:: 
     569        Verify that we cache based on the proof value and the algorithm choice:: 
    558570 
    559571            sage: E._get_local_data(p, False) is E._get_local_data(p, True) 
    560572            False 
     573 
     574            sage: E._get_local_data(p, None, "pari") is E._get_local_data(p, None, "generic") 
     575            False 
    561576        """ 
    562577        try: 
    563             return self._local_data[P, proof] 
     578            return self._local_data[P, proof, algorithm] 
    564579        except AttributeError: 
    565580            self._local_data = {} 
    566581        except KeyError: 
    567582            pass 
    568583        from sage.schemes.elliptic_curves.ell_local_data import EllipticCurveLocalData     
    569         self._local_data[P, proof] = EllipticCurveLocalData(self, P, proof) 
    570         return self._local_data[P, proof]        
     584        self._local_data[P, proof, algorithm] = EllipticCurveLocalData(self, P, proof, algorithm) 
     585        return self._local_data[P, proof, algorithm]        
    571586 
    572     def local_minimal_model(self, P, proof = None): 
     587    def local_minimal_model(self, P, proof = None, algorithm="pari"): 
    573588        r""" 
    574589        Returns a model which is integral at all primes and minimal at `P`. 
    575590 
     
    581596          (default controlled by global proof module).  Note that the 
    582597          proof module is number_field, not elliptic_curves, since the 
    583598          functions that actually need the flag are in number fields. 
     599 
     600        - ``algorithm`` (string, default: "pari") -- Ignored unless the 
     601          base field is `\QQ`.  If "pari", use the PARI C-library 
     602          ``ellglobalred`` implementation of Tate's algorithm over 
     603          `\QQ`. If "generic", use the general number field 
     604          implementation. 
    584605                      
    585606        OUTPUT: 
    586607 
     
    609630            # We use the "number_field" flag because the actual proof dependence is in Pari's number field functions. 
    610631            proof = sage.structure.proof.proof.get_flag(None, "number_field") 
    611632 
    612         return self.local_data(P, proof).minimal_model() 
     633        return self.local_data(P, proof, algorithm).minimal_model() 
    613634 
    614635    def has_good_reduction(self, P): 
    615636        r"""