Changeset 7729:b4d53385d6c7


Ignore:
Timestamp:
12/15/07 02:03:44 (5 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Message:

Trac #1183 -- residue class fields (finish).

Location:
sage
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sage/modules/free_module_element.pyx

    r7724 r7729  
    10191019             
    10201020            if len(entries) != self.degree(): 
    1021                 raise ArithmeticError, "entries must be a list of length %s"%\ 
     1021                raise TypeError, "entries must be a list of length %s"%\ 
    10221022                            self.degree() 
    10231023            if coerce: 
  • sage/rings/finite_field.py

    r7673 r7729  
    419419 
    420420    def gen(self, n=0): 
     421        """ 
     422        Return generator of this finite field. 
     423         
     424        EXAMPLES: 
     425            sage: k = GF(13) 
     426            sage: k.gen() 
     427            1 
     428            sage: k.gen(1) 
     429            Traceback (most recent call last): 
     430            ... 
     431            IndexError: only one generator 
     432        """ 
     433        if n != 0: 
     434            raise IndexError, "only one generator" 
    421435        return self.__gen 
    422436 
  • sage/rings/finite_field_givaro.pyx

    r7513 r7729  
    596596        EXAMPLES: 
    597597            sage: k = GF(3^4, 'b'); k.gen() 
    598             b         
     598            b 
     599            sage: k.gen(1) 
     600            Traceback (most recent call last): 
     601            ... 
     602            IndexError: only one generator 
    599603        """ 
    600604        cdef int r 
  • sage/rings/number_field/number_field_ideal.py

    r7727 r7729  
    849849            Partially defined quotient map from Number Field in i with defining polynomial x^2 + 1 to an explicit vector space representation for the quotient of the ring of integers by (p,I) for the ideal I=Fractional ideal (-i - 2). 
    850850            sage: lift 
    851             Lifting map to Order in Number Field in i with defining polynomial x^2 + 1 from quotient of integers by Fractional ideal (-i - 2) 
     851            Lifting map to Maximal Order in Number Field in i with defining polynomial x^2 + 1 from quotient of integers by Fractional ideal (-i - 2) 
    852852        """ 
    853853        return quotient_char_p(self, p) 
     
    10211021    V, from_V, to_V = K.absolute_vector_space() 
    10221022    M = ZZ**(V.dimension()) 
    1023     C = [to_V(K(b.list())) for b in B] 
     1023    C = [to_V(K(b)) for b in B] 
    10241024    return M.span_of_basis(C) 
    10251025         
  • sage/rings/residue_field.pyx

    r7728 r7729  
    1313    841 
    1414 
     15We reduce mod a prime for which the ring of integers is not 
     16monogenic (i.e., 2 is an essential discriminant divisor): 
     17    sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8) 
     18    sage: F = K.factor_integer(2); F 
     19    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (a^2 - 2*a + 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4)) 
     20    sage: F[0][0].residue_field() 
     21    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1) 
     22    sage: F[1][0].residue_field() 
     23    Residue field of Fractional ideal (a^2 - 2*a + 3) 
     24    sage: F[2][0].residue_field() 
     25    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4) 
     26 
    1527AUTHORS: 
    1628    -- David Roe (2007-10-3): initial version 
     
    2436    sage: parent(a*a) 
    2537    Residue field in zbar of Fractional ideal (17) 
     38 
     39Reducing a curve modulo a prime: 
     40    sage: K.<s> = NumberField(x^2+23) 
     41    sage: OK = K.ring_of_integers() 
     42    sage: E = EllipticCurve([0,0,0,K(1),K(5)]) 
     43    sage: pp = K.factor_integer(13)[0][0] 
     44    sage: Fpp = OK.residue_field(pp) 
     45    sage: E.base_extend(Fpp) 
     46    Elliptic Curve defined by y^2  = x^3 + x + 5 over Residue field of Fractional ideal (13, s - 4) 
    2647""" 
    2748 
     
    5677residue_field_cache = {} 
    5778 
    58 def ResidueField(p, names = None, check = True, trygen=False): 
     79def ResidueField(p, names = None, check = True): 
    5980    """ 
    6081    A function that returns the residue class field of a prime ideal p 
     
    127148        else: 
    128149            names = None 
    129     key = (p, names, trygen) 
     150    key = (p, names) 
    130151    if residue_field_cache.has_key(key): 
    131152        k = residue_field_cache[key]() 
     
    152173    gen_ok = False 
    153174    from sage.matrix.constructor import matrix 
    154     if trygen: 
    155         # This optimization not ready yet.  
    156         try: 
    157             x = K.gen() 
    158             M = matrix(k, n+1, n, [to_vs(x**i).list() for i in range(n+1)]) 
    159             print M 
    160             W = M.transpose().echelon_form() 
    161             if M.rank() == n: 
    162                 PB = M.matrix_from_rows(range(n)) 
    163                 gen_ok = True 
    164                 f = R((-W.column(n)).list() + [1]) 
    165         except (TypeError, ZeroDivisionError): 
    166             pass 
     175    try: 
     176        x = K.gen() 
     177        M = matrix(k, n+1, n, [to_vs(x**i).list() for i in range(n+1)]) 
     178        W = M.transpose().echelon_form() 
     179        if M.rank() == n: 
     180            PB = M.matrix_from_rows(range(n)) 
     181            gen_ok = True 
     182            f = R((-W.column(n)).list() + [1]) 
     183    except (TypeError, ZeroDivisionError): 
     184        pass 
    167185    if not gen_ok: 
    168186        bad = True 
     
    200218    """ 
    201219    The class representing a generic residue field. 
     220 
     221    EXAMPLES: 
     222        sage: I = QQ[i].factor_integer(2)[0][0]; I 
     223        Fractional ideal (I + 1) 
     224        sage: k = I.residue_field(); k 
     225        Residue field of Fractional ideal (I + 1) 
     226        sage: type(k) 
     227        <class 'sage.rings.residue_field.ResidueFiniteField_prime_modn'> 
    202228    """ 
    203229    def __init__(self, p, f, intp): 
     
    233259    def lift(self, x): 
    234260        """ 
    235         Returns a lift of x to the Order, returning a "polynomial" in the generator with coefficients between 0 and p-1. 
    236          
     261        Returns a lift of x to the Order, returning a "polynomial" in the 
     262        generator with coefficients between 0 and $p-1$. 
     263 
    237264        EXAMPLES: 
    238265            sage: K.<a> = NumberField(x^3-7) 
     
    252279            return self.f.lift(x) 
    253280 
     281    def reduction_map(self): 
     282        """ 
     283        Return the partially defined reduction map from the number 
     284        field to this residue class field. 
     285 
     286        EXAMPLES: 
     287            sage: I = QQ[2^(1/3)].factor_integer(2)[0][0]; I 
     288            Fractional ideal (-a) 
     289            sage: k = I.residue_field(); k 
     290            Residue field of Fractional ideal (-a) 
     291            sage: pi = k.reduction_map(); pi  
     292            Partially defined reduction map from Number Field in a with defining polynomial x^3 - 2 to Residue field of Fractional ideal (-a) 
     293            sage: pi.domain() 
     294            Number Field in a with defining polynomial x^3 - 2 
     295            sage: pi.codomain() 
     296            Residue field of Fractional ideal (-a) 
     297        """ 
     298        return self._structure[0] 
     299 
     300    def lift_map(self): 
     301        """ 
     302        EXAMPLES: 
     303            sage: I = QQ[3^(1/3)].factor_integer(5)[1][0]; I 
     304            Fractional ideal (-a + 2) 
     305            sage: k = I.residue_field(); k 
     306            Residue field of Fractional ideal (-a + 2) 
     307            sage: f = k.lift_map(); f 
     308            Lifting map from Residue field of Fractional ideal (-a + 2) to Number Field in a with defining polynomial x^3 - 3 
     309            sage: f.domain() 
     310            Residue field of Fractional ideal (-a + 2) 
     311            sage: f.codomain() 
     312            Number Field in a with defining polynomial x^3 - 3 
     313            sage: f(k.0) 
     314            1 
     315        """ 
     316        return self._structure[1] 
     317 
    254318    def __cmp__(self, x): 
    255319        """ 
    256         Compares two residue fields: they are equal iff the primes defining them are equal. 
     320        Compares two residue fields: they are equal iff the primes 
     321        defining them are equal. 
    257322         
    258323        EXAMPLES: 
     
    273338 
    274339class ReductionMap: 
     340    """ 
     341    A reduction map from a (subset) of a number field to this residue 
     342    class field.  
     343 
     344    EXAMPLES: 
     345        sage: I = QQ[sqrt(17)].factor_integer(5)[0][0]; I 
     346        Fractional ideal (5) 
     347        sage: k = I.residue_field(); k 
     348        Residue field in sqrt17bar of Fractional ideal (5) 
     349        sage: R = k.reduction_map(); R 
     350        Partially defined reduction map from Number Field in sqrt17 with defining polynomial x^2 - 17 to Residue field in sqrt17bar of Fractional ideal (5) 
     351    """ 
    275352    def __init__(self, K, F, to_vs, PBinv): 
     353        """ 
     354        Create a reduction map. 
     355 
     356        EXAMPLES: 
     357            sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8) 
     358            sage: F = K.factor_integer(2)[0][0].residue_field() 
     359            sage: F.reduction_map() 
     360            Partially defined reduction map from Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8 to Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1) 
     361        """ 
    276362        self.__K = K 
    277363        self.__F = F   # finite field 
     
    279365        self.__PBinv = PBinv 
    280366 
     367    def domain(self): 
     368        """ 
     369        Return the domain of this reduction map. 
     370 
     371        EXAMPLES: 
     372            sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 32) 
     373            sage: F = K.factor_integer(2)[0][0].residue_field() 
     374            sage: F.reduction_map().domain() 
     375            Number Field in a with defining polynomial x^3 + x^2 - 2*x + 32 
     376        """ 
     377        return self.__K 
     378 
     379    def codomain(self): 
     380        """ 
     381        Return the codomain of this reduction map. 
     382 
     383        EXAMPLES: 
     384            sage: K.<a> = NumberField(x^3 + 128) 
     385            sage: F = K.factor_integer(2)[0][0].residue_field() 
     386            sage: F.reduction_map().codomain() 
     387            Residue field of Fractional ideal (-1/4*a)         
     388        """ 
     389        return self.__F 
     390 
    281391    def __call__(self, x): 
     392        """ 
     393        Apply this reduction map to an element that coerces into the number field. 
     394 
     395        If x doesn't map because the denominator is not coprime to the 
     396        prime ideal, then a ZeroDivisionError exception is raised.  
     397 
     398        EXAMPLES: 
     399            sage: K.<a> = NumberField(x^2 + 1) 
     400            sage: F = K.factor_integer(2)[0][0].residue_field() 
     401            sage: r = F.reduction_map(); r 
     402            Partially defined reduction map from Number Field in a with defining polynomial x^2 + 1 to Residue field of Fractional ideal (a + 1) 
     403            sage: r(2 + a) 
     404            1 
     405            sage: r(a/2) 
     406            Traceback (most recent call last): 
     407            ... 
     408            ZeroDivisionError: Inverse does not exist. 
     409        """ 
    282410        # The reduction map is just x |--> F(to_vs(x) * (PB**(-1))) 
    283411        x = self.__K(x) 
     
    285413 
    286414    def __repr__(self): 
     415        """ 
     416        EXAMPLES: 
     417            sage: K.<theta_5> = CyclotomicField(5) 
     418            sage: F = K.factor_integer(7)[0][0].residue_field() 
     419            sage: F.reduction_map().__repr__() 
     420            'Partially defined reduction map from Cyclotomic Field of order 5 and degree 4 to Residue field in theta_5bar of Fractional ideal (7)' 
     421        """ 
    287422        return "Partially defined reduction map from %s to %s"%(self.__K, self.__F) 
    288423 
    289424class LiftingMap: 
     425    """ 
     426    Lifting map from residue class field to number field. 
     427 
     428    EXAMPLES: 
     429        sage: K.<a> = NumberField(x^3 + 2) 
     430        sage: F = K.factor_integer(5)[0][0].residue_field() 
     431        sage: F.degree() 
     432        2 
     433        sage: L = F.lift_map(); L 
     434        Lifting map from Residue field in abar of Fractional ideal (a^2 + 2*a - 1) to Number Field in a with defining polynomial x^3 + 2 
     435        sage: L(F.0^2) 
     436        3*a + 1 
     437        sage: L(3*a + 1) == F.0^2 
     438        True 
     439    """ 
    290440    def __init__(self, K, F, to_order, PB): 
     441        """ 
     442        Create a lifting map. 
     443 
     444        EXAMPLES: 
     445            sage: K.<theta_5> = CyclotomicField(5) 
     446            sage: F = K.factor_integer(7)[0][0].residue_field() 
     447            sage: F.lift_map() 
     448            Lifting map from Residue field in theta_5bar of Fractional ideal (7) to Cyclotomic Field of order 5 and degree 4 
     449        """ 
    291450        self.__K = K 
    292451        self.__F = F   # finite field 
     
    294453        self.__PB = PB 
    295454 
     455    def domain(self): 
     456        """ 
     457        Return the domain of this lifting map. 
     458 
     459        EXAMPLES: 
     460            sage: K.<a> = NumberField(x^5 + 2) 
     461            sage: F = K.factor_integer(7)[0][0].residue_field() 
     462            sage: L = F.lift_map(); L 
     463            Lifting map from Residue field in abar of Fractional ideal (-2*a^4 + a^3 - 4*a^2 + 2*a - 1) to Number Field in a with defining polynomial x^5 + 2 
     464            sage: L.domain() 
     465            Residue field in abar of Fractional ideal (-2*a^4 + a^3 - 4*a^2 + 2*a - 1) 
     466        """ 
     467        return self.__F 
     468 
     469    def codomain(self): 
     470        """ 
     471        Return the codomain of this lifting map. 
     472 
     473        EXAMPLES: 
     474            sage: K.<a> = CyclotomicField(7) 
     475            sage: F = K.factor_integer(5)[0][0].residue_field() 
     476            sage: L = F.lift_map(); L 
     477            Lifting map from Residue field in abar of Fractional ideal (5) to Cyclotomic Field of order 7 and degree 6 
     478            sage: L.codomain() 
     479            Cyclotomic Field of order 7 and degree 6         
     480        """ 
     481        return self.__K 
     482 
    296483    def __call__(self, x): 
     484        """ 
     485        Lift from this residue class field to the number field. 
     486 
     487        EXAMPLES: 
     488            sage: K.<a> = CyclotomicField(7) 
     489            sage: F = K.factor_integer(5)[0][0].residue_field() 
     490            sage: L = F.lift_map(); L 
     491            Lifting map from Residue field in abar of Fractional ideal (5) to Cyclotomic Field of order 7 and degree 6 
     492            sage: L(F.0) 
     493            a 
     494            sage: F(a) 
     495            abar 
     496        """ 
    297497        # The lifting map is just x |--> to_order(x * PB) 
    298498        x = self.__F(x) 
     
    301501 
    302502    def __repr__(self): 
     503        """ 
     504        EXAMPLES: 
     505            sage: K.<theta_12> = CyclotomicField(12) 
     506            sage: F.<tmod> = K.factor_integer(7)[0][0].residue_field() 
     507            sage: F.lift_map().__repr__() 
     508            'Lifting map from Residue field in tmod of Fractional ideal (-3*theta_12^2 + 1) to Cyclotomic Field of order 12 and degree 4' 
     509        """ 
    303510        return "Lifting map from %s to %s"%(self.__F, self.__K) 
    304511 
     
    586793                raise TypeError 
    587794 
    588         #try: 
    589         #    return self.coerce_map_from(self.f.domain())(self.f.domain()(x)) 
    590         #except (AttributeError, TypeError): 
    591         #    return FiniteField_givaro.__call__(self, x) 
    592  
    593  
     795 
     796 
Note: See TracChangeset for help on using the changeset viewer.