Ticket #14963: trac_14963-reviewer.patch

File trac_14963-reviewer.patch, 8.6 KB (added by pbruin, 8 years ago)
  • sage/libs/pari/gen.pyx

    # HG changeset patch
    # User Peter Bruin <peter.bruin@math.uzh.ch>
    # Date 1375827762 -7200
    # Node ID 7874e4d762704fcec38e92ff1989924a3dba37b1
    # Parent  34be43cc5493896fa8e1db8a8715f3cc977298e3
    Trac 14963: reviewer patch
    
    diff --git a/sage/libs/pari/gen.pyx b/sage/libs/pari/gen.pyx
    a b  
    69636963    def bnfissunit(self, sunit_data, x):
    69646964        t0GEN(x)
    69656965        t1GEN(sunit_data)
    6966         sig_on()
     6966        pari_catch_sig_on()
    69676967        return self.new_gen(bnfissunit(self.g, t1, t0))
    69686968
    69696969    def dirzetak(self, n):
  • sage/rings/number_field/number_field.py

    diff --git a/sage/rings/number_field/number_field.py b/sage/rings/number_field/number_field.py
    a b  
    34633463       .. note::
    34643464
    34653465            For more functionality see the S_unit_group() function.
    3466        
     3466
    34673467        EXAMPLE::
    34683468
    34693469            sage: K.<a> = QuadraticField(-3)
     
    53885388        .. note::
    53895389
    53905390           The group is cached.
    5391        
    5392         EXAMPLES::
    5393 
    5394             sage: x = polygen(QQ)                                                 
     5391
     5392        EXAMPLES::
     5393
     5394            sage: x = polygen(QQ)
    53955395            sage: K.<a> = NumberField(x^4 - 10*x^3 + 20*5*x^2 - 15*5^2*x + 11*5^3)
    5396             sage: U = K.S_unit_group(S=a); U                                     
     5396            sage: U = K.S_unit_group(S=a); U
    53975397            S-unit group with structure C10 x Z x Z x Z of Number Field in a with defining polynomial x^4 - 10*x^3 + 100*x^2 - 375*x + 1375 with S = (Fractional ideal (11, 1/275*a^3 + 4/55*a^2 - 5/11*a + 9), Fractional ideal (5, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5))
    53985398            sage: U.gens()
    53995399            (u0, u1, u2, u3)
    54005400            sage: U.gens_values()
    5401             [-7/275*a^3 + 1/11*a^2 - 9/11*a - 1, 6/275*a^3 - 9/55*a^2 + 14/11*a - 2, 14/275*a^3 - 21/55*a^2 + 29/11*a - 6, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5]
     5401            [-7/275*a^3 + 1/11*a^2 - 9/11*a - 1, 6/275*a^3 - 9/55*a^2 + 14/11*a - 2, 14/275*a^3 - 21/55*a^2 + 29/11*a - 6, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5]  # 32-bit
     5402            [-7/275*a^3 + 1/11*a^2 - 9/11*a - 1, 6/275*a^3 - 9/55*a^2 + 14/11*a - 2, -14/275*a^3 + 21/55*a^2 - 29/11*a + 6, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5]  # 64-bit
    54025403            sage: U.invariants()
    54035404            (10, 0, 0, 0)
    54045405            sage: [u.multiplicative_order() for u in U.gens()]
    54055406            [10, +Infinity, +Infinity, +Infinity]
    5406             sage: U.primes() 
     5407            sage: U.primes()
    54075408            (Fractional ideal (11, 1/275*a^3 + 4/55*a^2 - 5/11*a + 9), Fractional ideal (5, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5))
    54085409
    54095410        With the default value of `S`, the S-unit group is the same as
     
    54115412
    54125413            sage: x = polygen(QQ)
    54135414            sage: K.<a> = NumberField(x^3 + 3)
    5414             sage: U = K.unit_group(proof=False)   
     5415            sage: U = K.unit_group(proof=False)
    54155416            sage: U == K.S_unit_group(proof=False)
    54165417            True
    54175418
     
    54465447            (2, 0, 0, 0, 0)
    54475448            sage: u = U.exp((3,1,4,1,5)); u
    54485449            -6*a^2 + 18*a - 54
    5449             sage: u.norm().factor()       
     5450            sage: u.norm().factor()
    54505451            -1 * 2^9 * 3^5
    5451             sage: U.log(u)                 
     5452            sage: U.log(u)
    54525453            (1, 1, 4, 1, 5)
    5453            
    5454 
    5455         """
     5454
     5455        """
    54565456        proof = proof_flag(proof)
    54575457
    54585458        # process the parameter S:
  • sage/rings/number_field/unit_group.py

    diff --git a/sage/rings/number_field/unit_group.py b/sage/rings/number_field/unit_group.py
    a b  
    7979    S-unit group with structure C2 x Z x Z x Z x Z of Number Field in a with defining polynomial x^6 + 2 with S = (Fractional ideal (3, a + 1), Fractional ideal (3, a - 1))
    8080    sage: SUK.primes()
    8181    (Fractional ideal (3, a + 1), Fractional ideal (3, a - 1))
    82     sage: SUK.rank() 
     82    sage: SUK.rank()
    8383    4
    8484    sage: SUK.gens_values()
    8585    [-1, a^2 + 1, a^5 + a^4 - a^2 - a - 1, a + 1, -a + 1]
     
    156156        sage: u = UK.an_element();  u
    157157        u0*u1
    158158        sage: u.value()
    159         -1/4*a^3 + 7/4*a^2 - 17/4*a + 19/4     # 32-bit
    160         -1/4*a^3 - 7/4*a^2 - 17/4*a - 19/4     # 64-bit
     159        -1/4*a^3 + 7/4*a^2 - 17/4*a + 19/4
    161160
    162161        sage: x = polygen(QQ)
    163162        sage: K.<a> = NumberField(x^4 + 23)
     
    191190
    192191        sage: SUK = UnitGroup(K,S=21); SUK
    193192        S-unit group with structure C26 x Z x Z x Z x Z x Z x Z x Z x Z x Z x Z of Cyclotomic Field of order 13 and degree 12 with S = (Fractional ideal (3, z^3 - z - 1), Fractional ideal (3, z^3 + z^2 + z - 1), Fractional ideal (3, z^3 + z^2 - 1), Fractional ideal (3, z^3 - z^2 - z - 1), Fractional ideal (7))
    194         sage: SUK.rank()     
     193        sage: SUK.rank()
    195194        10
    196195        sage: SUK.zeta_order()
    197196        26
     
    247246            (u0, u1, u2, u3, u4, u5)
    248247            sage: UK.gens_values() # random
    249248            [-z^11, z^5 + z^3, z^6 + z^5, z^9 + z^7 + z^5, z^9 + z^5 + z^4 + 1, z^5 + z]
    250             sage: SUK = UnitGroup(K,S=2); SUK 
     249            sage: SUK = UnitGroup(K,S=2); SUK
    251250            S-unit group with structure C26 x Z x Z x Z x Z x Z x Z of Cyclotomic Field of order 13 and degree 12 with S = (Fractional ideal (2),)
    252251
    253252            """
     
    278277            self.__S = S
    279278            self.__pS = pS = [P.pari_prime() for P in S]
    280279
    281         # compute the fundemental units via pari:
     280        # compute the fundamental units via pari:
    282281        fu = [K(u) for u in pK.bnfunit()]
    283282        self.__nfu = len(fu)
    284283
     
    351350        if self.__S:
    352351            m = pK.bnfissunit(self.__S_unit_data, pari(u)).mattranspose()
    353352            if m.ncols()==0:
    354                 raise ValueError, "%s is not an S-unit"%u               
     353                raise ValueError, "%s is not an S-unit"%u
    355354        else:
    356355            if not u.is_integral() or u.norm().abs() != 1:
    357356                raise ValueError, "%s is not a unit"%u
     
    392391            Unit group with structure C2 x Z of Number Field in a with defining polynomial x^3 - 2
    393392            sage: U._repr_()
    394393            'Unit group with structure C2 x Z of Number Field in a with defining polynomial x^3 - 2'
    395             sage: UnitGroup(NumberField(x^3 - 2, 'a'),S=2)   
     394            sage: UnitGroup(NumberField(x^3 - 2, 'a'),S=2)
    396395            S-unit group with structure C2 x Z x Z of Number Field in a with defining polynomial x^3 - 2 with S = (Fractional ideal (a),)
    397396        """
    398397        if self.__S:
     
    549548    def primes(self):
    550549        """
    551550        Return the (possibly empty) list of primes associated with this S-unit group.
    552        
     551
    553552        EXAMPLES::
    554553
    555             sage: K.<a> = QuadraticField(-23)     
     554            sage: K.<a> = QuadraticField(-23)
    556555            sage: S = tuple(K.ideal(3).prime_factors()); S
    557556            (Fractional ideal (3, 1/2*a - 1/2), Fractional ideal (3, 1/2*a + 1/2))
    558557            sage: U = UnitGroup(K,S=tuple(S)); U
    559558            S-unit group with structure C2 x Z x Z of Number Field in a with defining polynomial x^2 + 23 with S = (Fractional ideal (3, 1/2*a - 1/2), Fractional ideal (3, 1/2*a + 1/2))
    560             sage: U.primes() == S                     
     559            sage: U.primes() == S
    561560            True
    562561        """
    563562        return self.__S
     
    596595            (13, 6, 7, 8, 9, 10)
    597596
    598597        An S-unit example::
    599        
    600            sage: SUK = UnitGroup(K,S=2)           
     598
     599           sage: SUK = UnitGroup(K,S=2)
    601600           sage: v = (3,1,4,1,5,9,2)
    602601           sage: u = SUK.exp(v); u
    603602           -997204*z^11 - 2419728*z^10 - 413812*z^9 - 413812*z^8 - 2419728*z^7 - 997204*z^6 - 2129888*z^4 - 1616524*z^3 + 149364*z^2 - 1616524*z - 2129888
    604            sage: SUK.log(u)         
     603           sage: SUK.log(u)
    605604           (3, 1, 4, 1, 5, 9, 2)
    606            sage: SUK.log(u) == v   
     605           sage: SUK.log(u) == v
    607606           True
    608607        """
    609608        return self(u).exponents()
     
    642641            True
    643642
    644643        An S-unit example::
    645        
    646            sage: SUK = UnitGroup(K,S=2)           
     644
     645           sage: SUK = UnitGroup(K,S=2)
    647646           sage: v = (3,1,4,1,5,9,2)
    648647           sage: u = SUK.exp(v); u
    649648           -997204*z^11 - 2419728*z^10 - 413812*z^9 - 413812*z^8 - 2419728*z^7 - 997204*z^6 - 2129888*z^4 - 1616524*z^3 + 149364*z^2 - 1616524*z - 2129888
    650            sage: SUK.log(u)         
     649           sage: SUK.log(u)
    651650           (3, 1, 4, 1, 5, 9, 2)
    652            sage: SUK.log(u) == v   
     651           sage: SUK.log(u) == v
    653652           True
    654653        """
    655654        return prod([u**e for u,e in zip(self.gens_values(),exponents)], self.number_field().one_element())