Ticket #11685: trac_11685_pari_zero_list.patch

File trac_11685_pari_zero_list.patch, 1.6 KB (added by johanbosman, 22 months ago)
  • sage/rings/finite_rings/element_ext_pari.py

    # HG changeset patch
    # User Johan Bosman <johan.g.bosman@gmail.com>
    # Date 1313238271 -3600
    # Node ID 5c5f0c29b1595babf75f7b9890ce5abdfe0ac426
    # Parent  deec96694006a4a64290153462f827f44b3bcd57
    Trac 11685: Pari finite fields: zero created by list
    
    diff -r deec96694006 -r 5c5f0c29b159 sage/rings/finite_rings/element_ext_pari.py
    a b  
    105105            sage: pari(x) 
    106106            Mod(Mod(1, 3)*a^3 + Mod(2, 3)*a^2 + Mod(1, 3), Mod(1, 3)*a^11 + Mod(2, 3)*a^2 + Mod(1, 3)) 
    107107 
     108        As well as #11685:: 
     109             
     110            sage: K.<a> = GF(3^11) 
     111            sage: K([0]) 
     112            0 
     113            sage: K([0]) == 0 
     114            True 
     115 
    108116        If the list is longer than the degree, we just get the result 
    109117        modulo the modulus:: 
    110118 
     
    162170                # multiply it with _pari_one (which equals Mod(1,p)) to 
    163171                # fix the characteristic and then mod out by the modulus. 
    164172                # See #10486. 
    165                 self.__value = (pari(value).Polrev("a") * parent._pari_one()).Mod(parent._pari_modulus()) 
     173                value = pari(value) 
     174                if value: 
     175                    value = value.Polrev("a") 
     176                else: 
     177                    value = pari(0) 
     178                self.__value = (value * parent._pari_one()).Mod(parent._pari_modulus())  
    166179            else: 
    167180                try: 
    168181                    self.__value = pari(value).Mod(parent._pari_modulus())*parent._pari_one()