Ticket #9400: 9400_jd_review.patch

File 9400_jd_review.patch, 23.2 KB (added by jdemeyer, 10 years ago)

Apply on top of 9400_maximize_at_primes.patc

  • sage/libs/pari/gen.pyx

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1282386675 -7200
    # Node ID 268c9abb602e57269f1add27bab01f8d25a1b271
    # Parent  0d7ed532726625a43432b22169beca536ee81b8a
    [mq]: 9400_jd_review
    
    diff -r 0d7ed5327266 -r 268c9abb602e sage/libs/pari/gen.pyx
    a b  
    64306430        _sig_on
    64316431        return self.new_gen(modreverse(self.g))
    64326432
    6433     def nfbasis(self, long flag=0, p=0):
    6434         cdef gen _p
    6435         cdef GEN g
    6436         if p != 0:
    6437             _p = self.pari(p)
    6438             g = _p.g
    6439         else:
    6440             g = <GEN>NULL
    6441         _sig_on
    6442         return self.new_gen(nfbasis0(self.g, flag, g))
    6443 
    6444     def nfbasis_d(self, long flag=0, p=0):
     6433    def nfbasis(self, long flag=0, fa=0):
     6434        """
     6435        nfbasis(x, flag, fa): integral basis of the field QQ[a], where ``a`` is
     6436        a root of the polynomial x.
     6437       
     6438        Binary digits of ``flag`` mean:
     6439         - 1: assume that no square of a prime>primelimit divides the
     6440              discriminant of ``x``.
     6441         - 2: use round 2 algorithm instead of round 4.
     6442        If present, ``fa`` provides the matrix of a partial factorization of
     6443        the discriminant of ``x``, useful if one wants only an order maximal at
     6444        certain primes only.
     6445       
     6446        EXAMPLES::
     6447       
     6448            sage: pari('x^3 - 17').nfbasis()
     6449            [1, x, 1/3*x^2 - 1/3*x + 1/3]
     6450       
     6451        We test ``flag`` = 1, noting it gives it wrong result when the
     6452        discriminant (-4 * `p`^2 * `q` in the example below) has a big square
     6453        factor::
     6454       
     6455            sage: p = next_prime(10^10); q = next_prime(p)
     6456            sage: x = polygen(QQ); f = x^2 + p^2*q
     6457            sage: pari(f).nfbasis(1)   # Wrong result
     6458            [1, x]
     6459            sage: pari(f).nfbasis()    # Correct result
     6460            [1, 1/10000000019*x]
     6461            sage: pari(f).nfbasis(fa = "[2,2; %s,2]"%p)    # Correct result and faster
     6462            [1, 1/10000000019*x]
     6463       
     6464        TESTS::
     6465       
     6466            ``flag`` = 2 should give the same result:
     6467            sage: pari('x^3 - 17').nfbasis(flag = 2)
     6468            [1, x, 1/3*x^2 - 1/3*x + 1/3]
     6469        """
     6470        global t0
     6471        t0GEN(fa)
     6472        if typ(t0) != t_MAT:
     6473            t0 = <GEN>0
     6474        _sig_on
     6475        return self.new_gen(nfbasis0(self.g, flag, t0))
     6476
     6477    def nfbasis_d(self, long flag=0, fa=0):
    64456478        """
    64466479        nfbasis_d(x): Return a basis of the number field defined over QQ
    64476480        by x and its discriminant.
     
    64636496            sage: pari([-2,0,0,1]).Polrev().nfbasis_d()
    64646497            ([1, x, x^2], -108)
    64656498        """
    6466         cdef gen d
    6467         cdef GEN g
    6468        
    6469         if p:
    6470             g = (<gen>self.pari(p)).g
    6471         else:
    6472             g = <GEN>NULL
    6473            
    6474         _sig_on
    6475         nfb = self.new_gen(nfbasis(self.g, &t0, flag, g))
    6476         d = self.new_gen(t0)
    6477         return nfb, d
     6499        global t0
     6500        cdef GEN disc
     6501        t0GEN(fa)
     6502        if typ(t0) != t_MAT:
     6503            t0 = <GEN>0
     6504        _sig_on
     6505        B = self.new_gen_noclear(nfbasis(self.g, &disc, flag, t0))
     6506        D = self.new_gen(disc);
     6507        return B,D
    64786508
    64796509    def nfdisc(self, long flag=0, p=0):
    64806510        """
     
    65416571        x = f.variable()
    65426572        return x.Mod(f)
    65436573
    6544     def nfinit(self, long flag=0):
    6545         _sig_on
    6546         return P.new_gen(nfinit0(self.g, flag, prec))
     6574    def nfinit(self, long flag=0, long precision=0):
     6575        """
     6576        nfinit(pol, {flag=0}): ``pol`` being a nonconstant irreducible
     6577        polynomial, gives a vector containing all the data necessary for PARI
     6578        to compute in this number field.
     6579       
     6580        ``flag`` is optional and can be set to:
     6581         - 0: default
     6582         - 1: do not compute different
     6583         - 2: first use polred to find a simpler polynomial
     6584         - 3: outputs a two-element vector [nf,Mod(a,P)], where nf is as in 2
     6585              and Mod(a,P) is a polmod equal to Mod(x,pol) and P=nf.pol
     6586       
     6587        EXAMPLES::
     6588           
     6589            sage: pari('x^3 - 17').nfinit()
     6590            [x^3 - 17, [1, 1], -867, 3, [[1, 1.68006..., 2.57128...; 1, -0.340034... + 2.65083...*I, -1.28564... - 2.22679...*I], [1, 1.68006..., 2.57128...; 1, 2.31080..., -3.51243...; 1, -2.99087..., 0.941154...], [1, 2, 3; 1, 2, -4; 1, -3, 1], [3, 1, 0; 1, -11, 17; 0, 17, 0], [51, 0, 16; 0, 17, 3; 0, 0, 1], [17, 0, -1; 0, 0, 3; -1, 3, 2], [51, [-17, 6, -1; 0, -18, 3; 1, 0, -16]]], [2.57128..., -1.28564... - 2.22679...*I], [1, 1/3*x^2 - 1/3*x + 1/3, x], [1, 0, -1; 0, 0, 3; 0, 1, 1], [1, 0, 0, 0, -4, 6, 0, 6, -1; 0, 1, 0, 1, 1, -1, 0, -1, 3; 0, 0, 1, 0, 2, 0, 1, 0, 1]]
     6591           
     6592        TESTS::
     6593       
     6594        This example only works after increasing precision::
     6595       
     6596            sage: pari('x^2 + 10^100 + 1').nfinit(precision=64)
     6597            Traceback (most recent call last):
     6598            ...
     6599            PariError: precision too low (10)
     6600            sage: pari('x^2 + 10^100 + 1').nfinit()
     6601            [...]
     6602
     6603        Throw a PARI error which is not precer::
     6604       
     6605            sage: pari('1.0').nfinit()
     6606            Traceback (most recent call last):
     6607            ...
     6608            PariError: incorrect type (11)
     6609        """
     6610       
     6611        # If explicit precision is given, use only that
     6612        if precision:
     6613            return self._nfinit_with_prec(flag, precision)
     6614       
     6615        # Otherwise, start with 64 bits of precision and increase as needed:
     6616        precision = 64
     6617        while True:
     6618            try:
     6619                return self._nfinit_with_prec(flag, precision)
     6620            except PariError, err:
     6621                if err.errnum() == precer:
     6622                    precision *= 2
     6623                else:
     6624                    raise err
     6625
     6626    # NOTE: because of the way _sig_on and Cython exceptions work, this
     6627    # function MUST NOT be folded into nfinit() above. It has to be a
     6628    # seperate function.
     6629    def _nfinit_with_prec(self, long flag, long precision):
     6630        """
     6631        See ``self.nfinit()``.
     6632        """
     6633        _sig_on
     6634        return P.new_gen(nfinit0(self.g, flag, pbw(precision)))
    65476635
    65486636    def nfisisom(self, gen other):
    65496637        """
     
    68676955        _sig_on
    68686956        return self.new_gen(polgalois(self.g, prec))
    68696957
    6870     def nfgaloisconj(self, long flag=0, denom=None, long prec=0):
     6958    def nfgaloisconj(self, long flag=0, denom=None, long precision=0):
    68716959        r"""
    68726960        Edited from the pari documentation:
    68736961
     
    68946982        else:
    68956983            t0 = NULL
    68966984        _sig_on
    6897         return self.new_gen(galoisconj0(self.g, flag, t0, pbw(prec)))
     6985        return self.new_gen(galoisconj0(self.g, flag, t0, pbw(precision)))
    68986986
    68996987    def nfroots(self, poly):
    69006988        r"""
     
    92409328
    92419329cdef extern from "pari/pari.h":
    92429330    char *errmessage[]
    9243     int user
    9244     int errpile
    9245     int noer
     9331    int talker2, bugparier, alarmer, openfiler, talker, flagerr, impl, \
     9332        archer, notfuncer, precer, typeer, consister, user, errpile, \
     9333        overflower, matinv1, mattype1, arither1, primer1, invmoder, \
     9334        constpoler, notpoler, redpoler, zeropoler, operi, operf, gdiver, \
     9335        memer, negexper, sqrter5, noer
     9336    int warner, warnprec, warnfile, warnmem
    92469337
    92479338cdef extern from "misc.h":
    92489339    int     factorint_withproof_sage(GEN* ans, GEN x, GEN cutoff)
     
    92659356
    92669357    errmessage = staticmethod(__errmessage)
    92679358
     9359    def errnum(self):
     9360        r"""
     9361        Return the PARI error number corresponding to this exception.
     9362       
     9363        EXAMPLES::
     9364           
     9365            sage: try:
     9366            ...     pari('1/0')
     9367            ... except PariError, err:
     9368            ...     print err.errnum()
     9369            27
     9370        """
     9371        return self.args[0]
     9372
    92689373    def __repr__(self):
    9269         return "PariError(%d)"%self.args[0]
     9374        r"""
     9375        TESTS::
     9376           
     9377            sage: PariError(11)
     9378            PariError(11)
     9379        """
     9380        return "PariError(%d)"%self.errnum()
    92709381
    92719382    def __str__(self):
    9272         return "%s (%d)"%(self.errmessage(self.args[0]),self.args[0])
     9383        r"""
     9384        EXAMPLES::
     9385           
     9386            sage: try:
     9387            ...     pari('1/0')
     9388            ... except PariError, err:
     9389            ...     print err
     9390            division by zero (27)
     9391        """
     9392        return "%s (%d)"%(self.errmessage(self.errnum()), self.errnum())
     9393
    92739394
    92749395# We expose a trap function to C.
    92759396# If this function returns without raising an exception,
  • sage/rings/number_field/number_field.py

    diff -r 0d7ed5327266 -r 268c9abb602e sage/rings/number_field/number_field.py
    a b  
    24042404        """
    24052405        PARI number field corresponding to this field.
    24062406       
    2407         This is the number field constructed using nfinit. This is the same
     2407        This is the number field constructed using nfinit(). This is the same
    24082408        as the number field got by doing pari(self) or gp(self).
    24092409       
    24102410        EXAMPLES::
     
    24142414            sage: k.pari_nf()[:4]
    24152415            [x^4 - 3*x + 7, [0, 2], 85621, 1]
    24162416            sage: pari(k)[:4]
    2417             [x^4 - 3*x + 7, [0, 2], 85621, 1]       
     2417            [x^4 - 3*x + 7, [0, 2], 85621, 1]
    24182418       
    24192419        ::
    24202420       
     
    24362436        We illustrate the maximize_at_primes and assume_disc_small parameters::
    24372437       
    24382438            sage: p = next_prime(10^40); q = next_prime(p)
    2439             sage: K.<a> = NumberField(x^2 - p*q, maximize_at_primes=[p])
    24402439
    24412440        The following would take a very long time without the
    24422441        maximize_at_primes option above::
    24432442       
     2443            sage: K.<a> = NumberField(x^2 - p*q, maximize_at_primes=[p])
    24442444            sage: K.pari_nf()
    24452445            [x^2 - 100000000000000000000...]
    24462446
    2447         I'm not sure this really illustrates anything::
    2448        
    2449             sage: K.<a> = NumberField(x^2 - 3*5*7*11*13, assume_disc_small=True)
     2447        Since the discriminant is square-free, this also works::
     2448       
     2449            sage: K.<a> = NumberField(x^2 - p*q, assume_disc_small=True)
    24502450            sage: K.pari_nf()
    2451             [x^2 - 15015, [2, 0], 60060, 1, ...]
     2451            [x^2 - 100000000000000000000...]
    24522452        """
    24532453        if self.absolute_polynomial().denominator() != 1:
    24542454            raise TypeError, "Unable to coerce number field defined by non-integral polynomial to PARI."
     
    24562456            return self.__pari_nf
    24572457        except AttributeError:
    24582458            f = self.pari_polynomial()
    2459             if self._maximize_at_primes:
    2460                 v = self._normalize_prime_list(self._maximize_at_primes)
    2461                 m = self._pari_disc_factorization_matrix(v)
    2462                 s = str(f)
    2463                 # we use a string since the Sage wrapping of the pari
    2464                 # c library nfinit doesn't support the third option.
    2465                 k = pari('nfinit([%s,nfbasis(%s,0,%s)])'%(s,s,str(m)))
    2466             elif self._assume_disc_small:
    2467                 k = f.nfinit(1)
    2468             else:
    2469                 k = f.nfinit()
    2470             self.__pari_nf = k
     2459            self.__pari_nf = pari([f, self._pari_integral_basis()]).nfinit()
    24712460            return self.__pari_nf
    24722461
    2473     def _pari_init_(self):
    2474         """
    2475         Needed for conversion of number field to PARI.
     2462    def _pari_(self):
     2463        """
     2464        Converts this number field to PARI.
    24762465       
    24772466        This only works if the defining polynomial of this number field is
    24782467        integral and monic.
     
    24802469        EXAMPLES::
    24812470       
    24822471            sage: k = NumberField(x^2 + x + 1, 'a')
    2483             sage: k._pari_init_()
    2484             'nfinit(x^2 + x + 1)'
    24852472            sage: k._pari_()
    24862473            [x^2 + x + 1, [0, 1], -3, 1, ... [1, x], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1, 1, -1]]
    24872474            sage: pari(k)
    24882475            [x^2 + x + 1, [0, 1], -3, 1, ...[1, x], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1, 1, -1]]
    2489 
    2490         We illustrate the maximize_at_primes parameter::
    2491        
    2492             sage: p = next_prime(10^40); q = next_prime(p)
    2493             sage: K.<a> = NumberField(x^2 - p*q, maximize_at_primes=[p,q])
    2494 
    2495         Note that nfbasis is explicitly passed in::
    2496        
    2497             sage: K._pari_init_()
    2498             'nfinit(x^2 - 100000000000000000000000000000000000002600000000000000000000000000000000000016819,nfbasis(x^2 - 100000000000000000000000000000000000002600000000000000000000000000000000000016819,0,[10000000000000000000000000000000000000121, 1; 10000000000000000000000000000000000000139, 1]))'
    2499 
    2500 
    2501         We illustrate the assume_disc_small parameter (note the 1 option to nfinit)::
    2502        
    2503             sage: K.<a> = NumberField(x^2 - 3*5*7*11*13, assume_disc_small=True)
    2504             sage: K._pari_init_()
    2505             'nfinit(x^2 - 15015,1)'
    2506         """
    2507         f = str(self.pari_polynomial())
    2508         if self.absolute_polynomial().denominator() != 1:
    2509             raise TypeError, "Unable to coerce number field defined by non-integral polynomial to PARI."
    2510         if self._maximize_at_primes:
    2511             v = self._normalize_prime_list(self._maximize_at_primes)
    2512             m = self._pari_disc_factorization_matrix(v)
    2513             return 'nfinit(%s,nfbasis(%s,0,%s))'%(f,f,str(m))
    2514         elif self._assume_disc_small:
    2515             return 'nfinit(%s,1)'%f
    2516         else:
    2517             return 'nfinit(%s)'%f
    2518            
     2476        """
     2477        return self.pari_nf()
     2478       
     2479    def _pari_init_(self):
     2480        """
     2481        Converts this number field to PARI.
     2482       
     2483        This only works if the defining polynomial of this number field is
     2484        integral and monic.
     2485       
     2486        EXAMPLES::
     2487       
     2488            sage: k = NumberField(x^2 + x + 1, 'a')
     2489            sage: k._pari_init_()
     2490            '[x^2 + x + 1, [0, 1], -3, 1, ... [1, x], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1, 1, -1]]'
     2491            sage: gp(k)
     2492            [x^2 + x + 1, [0, 1], -3, 1, ...[1, x], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1, 1, -1]]
     2493        """
     2494        return str(self.pari_nf())
     2495
    25192496    def pari_bnf(self, certify=False, units=True):
    25202497        """
    25212498        PARI big number field corresponding to this field.
     
    28942871            sage: K.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
    28952872            [2, a + 1]
    28962873            sage: K.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
    2897             [2, a + 1, a]
     2874            [2, a + 1, a]    # 32-bit
     2875            [2, a + 1, -a]   # 64-bit
    28982876            sage: K.<a> = NumberField(polygen(QQ))
    28992877            sage: K.selmer_group([],5)
    29002878            []
     
    37223700            sage: K.integral_basis()
    37233701            [1, 1/2*a^2 + 1/2*a, a^2]
    37243702       
    3725         ALGORITHM: Uses the pari library.
     3703        ALGORITHM: Uses the pari library (via _pari_integral_basis).
    37263704        """
    37273705        return self.maximal_order(v=v).basis()
    37283706   
    3729     def _compute_integral_basis(self, v=None):
    3730         """
    3731         Internal function returning an integral basis of this number field;
    3732         used in the maximal_order() function.
    3733        
    3734         Note that this is *not* necessarily the same basis returned by
    3735         self.integral_basis().
     3707    def _pari_integral_basis(self, v=None):
     3708        """
     3709        Internal function returning an integral basis of this number field in
     3710        PARI format.
    37363711       
    37373712        INPUT:
    37383713       
     
    37443719        EXAMPLES::
    37453720       
    37463721            sage: K.<a> = NumberField(x^5 + 10*x + 1)
    3747             sage: K._compute_integral_basis()
    3748             [1, a, a^2, a^3, a^4]
     3722            sage: K._pari_integral_basis()
     3723            [1, x, x^2, x^3, x^4]
    37493724       
    37503725        Next we compute the ring of integers of a cubic field in which 2 is
    37513726        an "essential discriminant divisor", so the ring of integers is not
     
    37543729        ::
    37553730       
    37563731            sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
    3757             sage: K._compute_integral_basis()
    3758             [1, a, 1/2*a^2 - 1/2*a]
     3732            sage: K._pari_integral_basis()
     3733            [1, x, 1/2*x^2 - 1/2*x]
    37593734            sage: K.integral_basis()
    37603735            [1, 1/2*a^2 + 1/2*a, a^2]
    37613736        """
     
    37713746                B = f.nfbasis(1 if self._assume_disc_small else 0)
    37723747            else:
    37733748                m = self._pari_disc_factorization_matrix(v)
    3774                 B = f.nfbasis(p = m)
    3775 
    3776             basis = map(self, B)
    3777             self._integral_basis_dict[v] = basis
    3778             return basis
     3749                B = f.nfbasis(fa = m)
     3750
     3751            self._integral_basis_dict[v] = B
     3752            return B
    37793753
    37803754    def _pari_disc_factorization_matrix(self, v):
    37813755        """
     
    37903764            sage: f = x^3 + 17*x + 393; f.discriminant().factor()
    37913765            -1 * 5^2 * 29 * 5779
    37923766            sage: K.<a> = NumberField(f)
    3793             sage: K._pari_disc_factorization_matrix([5,29])
     3767            sage: fa = K._pari_disc_factorization_matrix([5,29]); fa
    37943768            [5, 2; 29, 1]
     3769            sage: fa.type()
     3770            't_MAT'
    37953771        """
    37963772        f = self.pari_polynomial()
    37973773        m = pari.matrix(len(v), 2)
     
    53515327        except KeyError:
    53525328            pass
    53535329
    5354         B = self._compute_integral_basis(v = v)
     5330        B = map(self, self._pari_integral_basis(v = v))
    53555331
    53565332        if len(v) == 0 or v is None:
    53575333            is_maximal = True
     
    71577133            p = sage.rings.arith.next_prime(p)
    71587134            if p % n == 1:
    71597135                return p
    7160 
    7161     def integral_basis(self, v=None):
    7162         """
    7163         Return a list of elements of this number field that are a basis for
    7164         the full ring of integers.
     7136   
     7137    def _pari_integral_basis(self, v=None):
     7138        """
     7139        Internal function returning an integral basis of this number field in
     7140        PARI format.
    71657141       
    71667142        This field is cyclomotic, so this is a trivial computation, since
    71677143        the power basis on the generator is an integral basis. Thus the v
     
    71697145       
    71707146        EXAMPLES::
    71717147       
    7172             sage: CyclotomicField(5).integral_basis()
    7173             [1, zeta5, zeta5^2, zeta5^3]
     7148            sage: CyclotomicField(5)._pari_integral_basis()
     7149            [1, x, x^2, x^3]
     7150            sage: len(CyclotomicField(137)._pari_integral_basis())
     7151            136
    71747152        """
    71757153        try:
    71767154            return self._integral_basis_dict[tuple()]
    71777155        except KeyError:
    7178             v = tuple()
    7179             z = self.gen()
    7180             a = self(1)
     7156            z = pari(self.gen())
     7157            a = pari(1)
    71817158            B = []
    71827159            for n in xrange(self.degree()):
    7183                 B.append(a)
     7160                B.append(a.lift())
    71847161                a *= z
    7185             self._integral_basis_dict[tuple()] = B
     7162            self._integral_basis_dict[tuple()] = pari(B)
    71867163            return B
    7187 
    7188     def _compute_integral_basis(self, v=None):
    7189         """
    7190         Alias for self.integral_basis().
    7191        
    7192         EXAMPLES::
    7193        
    7194             sage: len(CyclotomicField(137)._compute_integral_basis())
    7195             136
    7196             sage: CyclotomicField(17).integral_basis() == CyclotomicField(17)._compute_integral_basis()
    7197             True
    7198         """
    7199         return self.integral_basis(v=v)
    72007164       
    72017165               
    72027166    def zeta_order(self):
  • sage/rings/number_field/number_field_ideal_rel.py

    diff -r 0d7ed5327266 -r 268c9abb602e sage/rings/number_field/number_field_ideal_rel.py
    a b  
    414414            sage: K.<c> = F.extension(Y^2 - (1 + a)*(a + b)*a*b)
    415415            sage: I = K.ideal(3, c)
    416416            sage: J = I.ideal_below(); J
    417             Fractional ideal (-b)
     417            Fractional ideal (b)   # 32-bit
     418            Fractional ideal (-b)  # 64-bit
    418419            sage: J.number_field() == F
    419420            True
    420421        """
     
    592593            sage: I.relative_ramification_index()
    593594            2
    594595            sage: I.ideal_below()
    595             Fractional ideal (b)
     596            Fractional ideal (b)   # 32-bit
     597            Fractional ideal (-b)  # 64-bit
    596598            sage: K.ideal(b) == I^2
    597599            True
    598600        """
  • sage/rings/polynomial/polynomial_quotient_ring.py

    diff -r 0d7ed5327266 -r 268c9abb602e sage/rings/polynomial/polynomial_quotient_ring.py
    a b  
    689689        `x^2 + 31` from 12 to 2, i.e. we lose a generator of order 6::
    690690       
    691691            sage: S.S_class_group([K.ideal(a)])
    692             [((1/4*xbar^2 + 31/4, (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8, 1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16, -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8), 6, 1/16*xbar^3 - 5/16*xbar^2 + 31/16*xbar - 139/16), ((-1/4*xbar^2 - 23/4, (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8, -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16, 1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8), 2, -1/8*xbar^2 - 15/8)]
     692            [((1/4*xbar^2 + 31/4, (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8, 1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16, -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8), 6, 1/16*xbar^3 - 5/16*xbar^2 + 31/16*xbar - 139/16), ((-1/4*xbar^2 - 23/4, (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8, -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16, 1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8), 2, -1/8*xbar^2 - 15/8)]  # 32-bit
     693            [((1/4*xbar^2 + 31/4, (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8, 1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16, -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8), 6, -1/16*xbar^3 + 1/16*xbar^2 - 31/16*xbar + 47/16), ((-1/4*xbar^2 - 23/4, (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8, -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16, 1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8), 2, -1/8*xbar^2 - 15/8)]  # 64-bit
    693694
    694695        Note that all the returned values live where we expect them to::
    695696       
     
    10691070            sage: D.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
    10701071            [2, -a - 1]
    10711072            sage: D.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
    1072             [2, -a - 1, a]   # 32-bit
    1073             [2, -a - 1, -a]  # 64-bit
     1073            [2, -a - 1, -a]  # 32-bit
     1074            [2, -a - 1, a]   # 64-bit
    10741075
    10751076        """
    10761077        units, clgp_gens = self._S_class_group_and_units(tuple(S), proof=proof)
  • sage/rings/residue_field.pyx

    diff -r 0d7ed5327266 -r 268c9abb602e sage/rings/residue_field.pyx
    a b  
    468468       
    469469            sage: K.<a> = NumberField(x^3-11)
    470470            sage: F = K.ideal(37).factor(); F
    471             (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5)) * (Fractional ideal (37, a + 9))  # 32-bit
    472             (Fractional ideal (37, a + 12)) * (Fractional ideal  (2*a - 5)) * (Fractional ideal (37, a + 9))  # 64-bit
     471            (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5)) * (Fractional ideal (37, a + 9))   # 32-bit
     472            (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5)) * (Fractional ideal (37, a + 9))  # 64-bit
    473473            sage: k = K.residue_field(F[0][0])
    474474            sage: l = K.residue_field(F[1][0])
    475475            sage: k == l