Ticket #9400: trac_9400.patch
File trac_9400.patch, 47.3 KB (added by , 12 years ago) |
---|
-
sage/modular/cusps_nf.py
# HG changeset patch # User William Stein <wstein@gmail.com> # Date 1277963819 25200 # Node ID d912407af0aee59b9612dfe4b53f288e716c5edd # Parent 5a26560c3ceded43f0115375e8a8b97de0a253b1 trac 9400: modify the NumberField constructor to pass in optional integer B such that all the internal pari routines will replace the discriminant by its gcd with B, making some things massively faster; etc. diff --git a/sage/modular/cusps_nf.py b/sage/modular/cusps_nf.py
a b 140 140 sage: N = k.ideal(713, a + 208) 141 141 sage: L = list_of_representatives(N); L 142 142 (Fractional ideal (1), 143 Fractional ideal ( 37, a + 12),144 Fractional ideal ( 47, a - 9))143 Fractional ideal (a + 12, 37), 144 Fractional ideal (a - 9, 47)) 145 145 146 146 The output of ``list_of_representatives`` has been cached: 147 147 … … 151 151 [Fractional ideal (713, a + 208)] 152 152 sage: sage.modular.cusps_nf._list_reprs_cache[N] 153 153 (Fractional ideal (1), 154 Fractional ideal ( 37, a + 12),155 Fractional ideal ( 47, a - 9))154 Fractional ideal (a + 12, 37), 155 Fractional ideal (a - 9, 47)) 156 156 """ 157 157 if _list_reprs_cache.has_key(N): 158 158 lreps = _list_reprs_cache[N] … … 1291 1291 from sage.misc.mrange import xmrange 1292 1292 from sage.misc.misc import prod 1293 1293 1294 return [prod([u**e for u,e in zip(ulist,ei)],k(1)) for ei in xmrange(elist)] 1295 No newline at end of file 1294 return [prod([u**e for u,e in zip(ulist,ei)],k(1)) for ei in xmrange(elist)] -
sage/rings/number_field/class_group.py
diff --git a/sage/rings/number_field/class_group.py b/sage/rings/number_field/class_group.py
a b 162 162 sage: G 163 163 Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^4 + 23 164 164 sage: list(G) 165 [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 + a - 1/2), Fractional ideal class (2, 1/2*a^2 + 1/2)] # 32-bit 166 [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 - a + 3/2), Fractional ideal class (2, 1/2*a^2 + 1/2)] # 64-bit 165 [Trivial principal fractional ideal class, Fractional ideal class (a + 1, 1/4*a^3 + 1/4*a^2 + 1/4*a + 1/4, 2, 1/2*a^2 + 1/2), Fractional ideal class (1/4*a^3 + 1/4*a^2 + 5/4*a + 5/4, 2, 2*a, 1/2*a^2 + 1/2)] 167 166 sage: G.list() 168 [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 + a - 1/2), Fractional ideal class (2, 1/2*a^2 + 1/2)] # 32-bit 169 [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 - a + 3/2), Fractional ideal class (2, 1/2*a^2 + 1/2)] # 64-bit 167 [Trivial principal fractional ideal class, Fractional ideal class (a + 1, 1/4*a^3 + 1/4*a^2 + 1/4*a + 1/4, 2, 1/2*a^2 + 1/2), Fractional ideal class (1/4*a^3 + 1/4*a^2 + 5/4*a + 5/4, 2, 2*a, 1/2*a^2 + 1/2)] 170 168 171 169 TESTS:: 172 170 -
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 246 246 247 247 248 248 _nf_cache = {} 249 def NumberField(polynomial, name=None, check=True, names=None, cache=True, embedding=None, latex_name=None): 249 def NumberField(polynomial, name=None, check=True, names=None, cache=True, 250 embedding=None, latex_name=None, 251 assume_disc_small=False, 252 maximize_at_primes=None): 250 253 r""" 251 254 Return *the* number field defined by the given irreducible 252 255 polynomial and with variable with the given name. If check is True … … 255 258 256 259 INPUT: 257 260 258 - ``polynomial`` - a polynomial over `\QQ` or a number 259 field, or a list of polynomials. 260 - ``name`` - a string (default: 'a'), the name of the 261 generator 262 - ``check`` - bool (default: True); do type checking 263 and irreducibility checking. 264 - ``embedding`` - image of the generator in an ambient 265 field (default: None) 261 - ``polynomial`` - a polynomial over `\QQ` or a number field, 262 or a list of polynomials. 263 - ``name`` - a string (default: 'a'), the name of the generator 264 - ``check`` - bool (default: True); do type checking and 265 irreducibility checking. 266 - ``embedding`` - image of the generator in an ambient field 267 (default: None) 268 - ``assume_disc_small`` -- (default: False); if True, assume 269 that no square of a prime greater than PARI's primelimit 270 (which should be 500000); only applies for absolute fields 271 at present. 272 - ``maximize_at_primes`` -- (default: None) None or a list of 273 primes; if not None, then the maximal order is computed by 274 maximizing only at the primes in this list, which completely 275 avoids having to factor the discriminant, but of course can 276 lead to wrong results; only applies for absolute fields at 277 present. 266 278 267 279 EXAMPLES:: 268 280 … … 452 464 453 465 if cache: 454 466 key = (polynomial, polynomial.base_ring(), name, latex_name, 455 embedding, embedding.parent() if embedding is not None else None) 467 embedding, embedding.parent() if embedding is not None else None, 468 assume_disc_small, None if maximize_at_primes is None else tuple(maximize_at_primes)) 456 469 if _nf_cache.has_key(key): 457 470 K = _nf_cache[key]() 458 471 if not K is None: return K … … 464 477 return S 465 478 466 479 if polynomial.degree() == 2: 467 K = NumberField_quadratic(polynomial, name, latex_name, check, embedding) 480 K = NumberField_quadratic(polynomial, name, latex_name, check, embedding, 481 assume_disc_small=assume_disc_small, maximize_at_primes=maximize_at_primes) 468 482 else: 469 K = NumberField_absolute(polynomial, name, latex_name, check, embedding) 483 K = NumberField_absolute(polynomial, name, latex_name, check, embedding, 484 assume_disc_small=assume_disc_small, maximize_at_primes=maximize_at_primes) 470 485 471 486 if cache: 472 487 _nf_cache[key] = weakref.ref(K) … … 926 941 """ 927 942 def __init__(self, polynomial, name, 928 943 latex_name=None, check=True, embedding=None, 929 category = None): 944 category = None, 945 assume_disc_small=False, maximize_at_primes=None): 930 946 """ 931 947 Create a number field. 932 948 … … 978 994 ... 979 995 TypeError: polynomial must be defined over rational field 980 996 """ 981 997 self._assume_disc_small = assume_disc_small 998 self._maximize_at_primes = maximize_at_primes 982 999 from sage.categories.number_fields import NumberFields 983 1000 default_category = NumberFields() 984 1001 if category is None: … … 2165 2182 2166 2183 sage: x = ZZ['x'].gen() 2167 2184 sage: F.<t> = NumberField(x^3 - 2) 2168 2185 2169 2186 :: 2170 2187 2171 2188 sage: P2 = F.prime_above(2) … … 2414 2431 Traceback (most recent call last): 2415 2432 ... 2416 2433 TypeError: Unable to coerce number field defined by non-integral polynomial to PARI. 2434 2435 We illustrate the maximize_at_primes and assume_disc_small parameters:: 2436 2437 sage: p = next_prime(10^40); q = next_prime(p) 2438 sage: K.<a> = NumberField(x^2 - p*q, maximize_at_primes=[p]) 2439 2440 The following would take a very long time without the 2441 maximize_at_primes option above:: 2442 2443 sage: K.pari_nf() 2444 [x^2 - 100000000000000000000...] 2445 2446 I'm not sure this really illustrates anything:: 2447 2448 sage: K.<a> = NumberField(x^2 - 3*5*7*11*13, assume_disc_small=True) 2449 sage: K.pari_nf() 2450 [x^2 - 15015, [2, 0], 60060, 1, ...] 2417 2451 """ 2418 2452 if self.absolute_polynomial().denominator() != 1: 2419 2453 raise TypeError, "Unable to coerce number field defined by non-integral polynomial to PARI." … … 2421 2455 return self.__pari_nf 2422 2456 except AttributeError: 2423 2457 f = self.pari_polynomial() 2424 self.__pari_nf = f.nfinit() 2458 if self._maximize_at_primes: 2459 v = self._normalize_prime_list(self._maximize_at_primes) 2460 m = self._pari_disc_factorization_matrix(v) 2461 s = str(f) 2462 # we use a string since the Sage wrapping of the pari 2463 # c library nfinit doesn't support the third option. 2464 k = pari('nfinit([%s,nfbasis(%s,0,%s)])'%(s,s,str(m))) 2465 elif self._assume_disc_small: 2466 k = f.nfinit(1) 2467 else: 2468 k = f.nfinit() 2469 self.__pari_nf = k 2425 2470 return self.__pari_nf 2426 2471 2427 2472 def _pari_init_(self): … … 2440 2485 [x^2 + x + 1, [0, 1], -3, 1, ... [1, x], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1, 1, -1]] 2441 2486 sage: pari(k) 2442 2487 [x^2 + x + 1, [0, 1], -3, 1, ...[1, x], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1, 1, -1]] 2443 """ 2488 2489 We illustrate the maximize_at_primes parameter:: 2490 2491 sage: p = next_prime(10^40); q = next_prime(p) 2492 sage: K.<a> = NumberField(x^2 - p*q, maximize_at_primes=[p,q]) 2493 2494 Note that nfbasis is explicitly passed in:: 2495 2496 sage: K._pari_init_() 2497 'nfinit(x^2 - 100000000000000000000000000000000000002600000000000000000000000000000000000016819,nfbasis(x^2 - 100000000000000000000000000000000000002600000000000000000000000000000000000016819,0,[10000000000000000000000000000000000000121, 1; 10000000000000000000000000000000000000139, 1]))' 2498 2499 2500 We illustrate the assume_disc_small parameter (note the 1 option to nfinit):: 2501 2502 sage: K.<a> = NumberField(x^2 - 3*5*7*11*13, assume_disc_small=True) 2503 sage: K._pari_init_() 2504 'nfinit(x^2 - 15015,1)' 2505 """ 2506 f = str(self.pari_polynomial()) 2444 2507 if self.absolute_polynomial().denominator() != 1: 2445 2508 raise TypeError, "Unable to coerce number field defined by non-integral polynomial to PARI." 2446 return 'nfinit(%s)'%self.pari_polynomial() 2447 2509 if self._maximize_at_primes: 2510 v = self._normalize_prime_list(self._maximize_at_primes) 2511 m = self._pari_disc_factorization_matrix(v) 2512 return 'nfinit(%s,nfbasis(%s,0,%s))'%(f,f,str(m)) 2513 elif self._assume_disc_small: 2514 return 'nfinit(%s,1)'%f 2515 else: 2516 return 'nfinit(%s)'%f 2517 2448 2518 def pari_bnf(self, certify=False, units=True): 2449 2519 """ 2450 2520 PARI big number field corresponding to this field. … … 3668 3738 3669 3739 ALGORITHM: Uses the pari library. 3670 3740 """ 3671 return self.maximal_order( ).basis()3741 return self.maximal_order(v=v).basis() 3672 3742 3673 3743 def _compute_integral_basis(self, v=None): 3674 3744 """ … … 3703 3773 sage: K.integral_basis() 3704 3774 [1, 1/2*a^2 + 1/2*a, a^2] 3705 3775 """ 3776 if (v is None or len(v) == 0) and self._maximize_at_primes: 3777 v = self._maximize_at_primes 3778 3706 3779 v = self._normalize_prime_list(v) 3707 3780 try: 3708 3781 return self._integral_basis_dict[v] 3709 3782 except: 3710 3783 f = self.pari_polynomial() 3711 3712 3784 if len(v) == 0: 3713 B = f.nfbasis() 3714 else: 3715 m = pari.matrix(len(v), 2) 3716 d = f.poldisc() 3717 for i in range(len(v)): 3718 p = pari(ZZ(v[i])) 3719 m[i,0] = p 3720 m[i,1] = d.valuation(p) 3785 B = f.nfbasis(1 if self._assume_disc_small else 0) 3786 else: 3787 m = self._pari_disc_factorization_matrix(v) 3721 3788 B = f.nfbasis(p = m) 3722 3789 3723 3790 basis = map(self, B) 3724 3791 self._integral_basis_dict[v] = basis 3725 3792 return basis 3726 3793 3794 def _pari_disc_factorization_matrix(self, v): 3795 """ 3796 Returns a PARI matrix representation for the partial 3797 factorization of the discriminant of the defining polynomial 3798 of self, defined by the list of primes in the Python list v. 3799 This function is used internally by the number fields code. 3800 3801 EXAMPLES:: 3802 3803 sage: x = polygen(QQ,'x') 3804 sage: f = x^3 + 17*x + 393; f.discriminant().factor() 3805 -1 * 5^2 * 29 * 5779 3806 sage: K.<a> = NumberField(f) 3807 sage: K._pari_disc_factorization_matrix([5,29]) 3808 [5, 2; 29, 1] 3809 """ 3810 f = self.pari_polynomial() 3811 m = pari.matrix(len(v), 2) 3812 d = f.poldisc() 3813 for i in range(len(v)): 3814 p = pari(ZZ(v[i])) 3815 m[i,0] = p 3816 m[i,1] = d.valuation(p) 3817 return m 3818 3819 3727 3820 def reduced_basis(self, prec=None): 3728 3821 r""" 3729 3822 This function returns an LLL-reduced basis for the … … 4248 4341 sage: K.<a> = NumberField(x^4+3*x^2-17) 4249 4342 sage: P = K.ideal(61).factor()[0][0] 4250 4343 sage: K.residue_field(P) 4251 Residue field in abar of Fractional ideal ( -2*a^2 +1)4344 Residue field in abar of Fractional ideal (a^2 + 30, 61) 4252 4345 4253 4346 :: 4254 4347 … … 4262 4355 sage: L.residue_field(P) 4263 4356 Traceback (most recent call last): 4264 4357 ... 4265 ValueError: Fractional ideal ( -2*a^2 +1) is not an ideal of Number Field in b with defining polynomial x^2 + 54358 ValueError: Fractional ideal (a^2 + 30, 61) is not an ideal of Number Field in b with defining polynomial x^2 + 5 4266 4359 sage: L.residue_field(2) 4267 4360 Traceback (most recent call last): 4268 4361 ... … … 4746 4839 4747 4840 class NumberField_absolute(NumberField_generic): 4748 4841 4749 def __init__(self, polynomial, name, latex_name=None, check=True, embedding=None): 4842 def __init__(self, polynomial, name, latex_name=None, check=True, embedding=None, 4843 assume_disc_small=False, maximize_at_primes=None): 4750 4844 """ 4751 4845 Function to initialize an absolute number field. 4752 4846 … … 4758 4852 <class 'sage.rings.number_field.number_field.NumberField_absolute_with_category'> 4759 4853 sage: TestSuite(K).run() 4760 4854 """ 4761 NumberField_generic.__init__(self, polynomial, name, latex_name, check, embedding) 4855 NumberField_generic.__init__(self, polynomial, name, latex_name, check, embedding, 4856 assume_disc_small=assume_disc_small, maximize_at_primes=maximize_at_primes) 4762 4857 self._element_class = number_field_element.NumberFieldElement_absolute 4763 4858 self._zero_element = self(0) 4764 4859 self._one_element = self(1) … … 6345 6440 sage: type(cf3(z1)) 6346 6441 <type 'sage.rings.number_field.number_field_element_quadratic.NumberFieldElement_quadratic'> 6347 6442 """ 6348 def __init__(self, n, names, embedding=None ):6443 def __init__(self, n, names, embedding=None, assume_disc_small=False, maximize_at_primes=None): 6349 6444 """ 6350 6445 A cyclotomic field, i.e., a field obtained by adjoining an n-th 6351 6446 root of unity to the rational numbers. … … 6376 6471 name= names, 6377 6472 latex_name=latex_name, 6378 6473 check=False, 6379 embedding = embedding) 6474 embedding = embedding, 6475 assume_disc_small=assume_disc_small, 6476 maximize_at_primes=maximize_at_primes) 6380 6477 if n%2: 6381 6478 self.__zeta_order = 2*n 6382 6479 else: … … 7163 7260 sage: CyclotomicField(17).integral_basis() == CyclotomicField(17)._compute_integral_basis() 7164 7261 True 7165 7262 """ 7166 return self.integral_basis( )7263 return self.integral_basis(v=v) 7167 7264 7168 7265 7169 7266 def zeta_order(self): … … 7370 7467 sage: QuadraticField(-4, 'b') 7371 7468 Number Field in b with defining polynomial x^2 + 4 7372 7469 """ 7373 def __init__(self, polynomial, name=None, latex_name=None, check=True, embedding=None): 7470 def __init__(self, polynomial, name=None, latex_name=None, check=True, embedding=None, 7471 assume_disc_small=False, maximize_at_primes=None): 7374 7472 """ 7375 7473 Create a quadratic number field. 7376 7474 … … 7394 7492 7395 7493 sage: TestSuite(k).run() 7396 7494 """ 7397 NumberField_absolute.__init__(self, polynomial, name=name, check=check, embedding=embedding, latex_name=latex_name) 7495 NumberField_absolute.__init__(self, polynomial, name=name, check=check, 7496 embedding=embedding, latex_name=latex_name, 7497 assume_disc_small=assume_disc_small, maximize_at_primes=maximize_at_primes) 7398 7498 self._element_class = number_field_element_quadratic.NumberFieldElement_quadratic 7399 7499 c, b, a = [rational.Rational(t) for t in self.defining_polynomial().list()] 7400 7500 # set the generator -
sage/rings/number_field/number_field_ideal.py
diff --git a/sage/rings/number_field/number_field_ideal.py b/sage/rings/number_field/number_field_ideal.py
a b 36 36 # http://www.gnu.org/licenses/ 37 37 #***************************************************************************** 38 38 39 SMALL_DISC = 1000000 40 39 41 import operator 40 42 41 43 import sage.misc.latex as latex … … 178 180 if len(gens)==0: 179 181 raise ValueError, "gens must have length at least 1 (zero ideal is not a fractional ideal)" 180 182 Ideal_generic.__init__(self, field, gens, coerce) 183 184 def __hash__(self): 185 """ 186 EXAMPLES:: 187 188 sage: NumberField(x^2 + 1, 'a').ideal(7).__hash__() 189 7225361069995395753 # 64-bit 190 -1895626071 # 32-bit 191 """ 192 try: return self._hash 193 # At some point in the future (e.g., for relative extensions), we'll likely 194 # have to consider other hashes, like the following. 195 #except AttributeError: self._hash = hash(self.gens()) 196 except AttributeError: self._hash = self.pari_hnf().__hash__() 197 return self._hash 181 198 182 199 def _latex_(self): 183 200 """ … … 188 205 '\\left(2, \\frac{1}{2} a - \\frac{1}{2}\\right)' 189 206 sage: latex(K.ideal([2, 1/2*a - 1/2])) 190 207 \left(2, \frac{1}{2} a - \frac{1}{2}\right) 208 209 The gens are reduced only if the norm of the discriminant of 210 the defining polynomial is at most 211 sage.rings.number_field.number_field_ideal.SMALL_DISC:: 212 213 sage: K.<a> = NumberField(x^2 + 902384092834); K 214 Number Field in a with defining polynomial x^2 + 902384092834 215 sage: I = K.factor(19)[0][0]; I._latex_() 216 '\\left(19\\right)' 217 218 We can make the generators reduced by increasing SMALL_DISC. 219 We had better also set proof to False, or computing reduced 220 gens could take too long:: 221 222 sage: proof.number_field(False) 223 sage: sage.rings.number_field.number_field_ideal.SMALL_DISC = 10^20 224 sage: K.<a> = NumberField(x^4 + 3*x^2 - 17) 225 sage: K.ideal([17*a,17,17,17*a])._latex_() 226 '\\left(17\\right)' 191 227 """ 192 return '\\left(%s\\right)'%(", ".join(map(latex.latex, self. gens_reduced())))228 return '\\left(%s\\right)'%(", ".join(map(latex.latex, self._gens_repr()))) 193 229 194 230 def __cmp__(self, other): 195 231 """ … … 363 399 364 400 def _repr_short(self): 365 401 """ 366 Efficient string representation of this fraction ideal. 402 Compact string representation of this fraction ideal. When 403 the norm of the discriminant of the defining polynomial of the 404 number field is less than 405 406 sage.rings.number_field.number_field_ideal.SMALL_DISC 407 408 then display reduced generators. Otherwise just display generators. 367 409 368 410 EXAMPLES:: 369 411 … … 372 414 sage: I = K.factor(17)[0][0]; I 373 415 Fractional ideal (17, a^2 - 6) 374 416 sage: I._repr_short() 375 '(17, a^2 - 6)' 417 '(17, a^2 - 6)' 418 419 We use reduced gens, because the discriminant is small:: 420 421 sage: K.<a> = NumberField(x^2 + 17); K 422 Number Field in a with defining polynomial x^2 + 17 423 sage: I = K.factor(17)[0][0]; I 424 Fractional ideal (a) 425 426 Here the discriminant is 'large', so the gens aren't reduced:: 427 428 sage: sage.rings.number_field.number_field_ideal.SMALL_DISC 429 1000000 430 sage: K.<a> = NumberField(x^2 + 902384094); K 431 Number Field in a with defining polynomial x^2 + 902384094 432 sage: I = K.factor(19)[0][0]; I 433 Fractional ideal (19, a + 14) 434 sage: I.gens_reduced() # long time 435 (19, a - 5) 376 436 """ 377 #NOTE -- we will *have* to not reduce the gens soon, since this 378 # makes things insanely slow in general. 379 # When I fix this, I *have* to also change the _latex_ method. 380 return '(%s)'%(', '.join(map(str, self.gens_reduced()))) 381 # return '(%s)'%(', '.join(map(str, self.gens()))) 437 return '(%s)'%(', '.join(map(str, self._gens_repr()))) 438 439 def _gens_repr(self): 440 """ 441 Returns tuple of generators to be used for printing this 442 number field idea. The gens are reduced only if the absolute 443 value of the norm of the discriminant of the defining 444 polynomial is at most 445 sage.rings.number_field.number_field_ideal.SMALL_DISC. 446 447 EXAMPLES:: 448 449 sage: sage.rings.number_field.number_field_ideal.SMALL_DISC 450 1000000 451 452 453 sage: K.<a> = NumberField(x^4 + 3*x^2 - 17) 454 sage: K.discriminant() # too big 455 -1612688 456 sage: I = K.ideal([17*a,17,17,17*a]); I._gens_repr() 457 (17, 17*a) 458 sage: I.gens_reduced() 459 (17,) 460 """ 461 # Small discriminant is easy to find nice gens -- otherwise it 462 # is potentially very hard 463 try: 464 if abs(self.number_field().defining_polynomial().discriminant().norm()) <= SMALL_DISC: 465 return self.gens_reduced() 466 except TypeError: 467 # In some cases with relative extensions, computing the 468 # discriminant of the defining polynomial is not 469 # supported. 470 pass 471 # Return unique sorted generators. This eliminates the common case 472 # where self.gens() is something like (17, 17), which looks silly. 473 return tuple(sorted(set(self.gens()))) 474 382 475 383 476 def _pari_(self): 384 477 """ … … 1294 1387 sage: K.<a> = CyclotomicField(11); K 1295 1388 Cyclotomic Field of order 11 and degree 10 1296 1389 sage: I = K.factor(31)[0][0]; I 1297 Fractional ideal ( -3*a^7 - 4*a^5 - 3*a^4 - 3*a^2 - 3*a - 3)1390 Fractional ideal (a^5 + 10*a^4 - a^3 + a^2 + 9*a - 1, 31) 1298 1391 sage: I.divides(I) 1299 1392 True 1300 1393 sage: I.divides(31) … … 1317 1410 sage: I = K.ideal(19); I 1318 1411 Fractional ideal (19) 1319 1412 sage: F = I.factor(); F 1320 (Fractional ideal (a^2 + 2*a + 2 )) * (Fractional ideal (a^2 - 2*a + 2))1413 (Fractional ideal (a^2 + 2*a + 2, 19)) * (Fractional ideal (19, a^2 - 2*a + 2)) 1321 1414 sage: type(F) 1322 1415 <class 'sage.structure.factorization.Factorization'> 1323 1416 sage: list(F) 1324 [(Fractional ideal (a^2 + 2*a + 2 ), 1), (Fractional ideal (a^2 - 2*a + 2), 1)]1417 [(Fractional ideal (a^2 + 2*a + 2, 19), 1), (Fractional ideal (19, a^2 - 2*a + 2), 1)] 1325 1418 sage: F.prod() 1326 Fractional ideal (19 )1419 Fractional ideal (19*a^2 + 38*a + 38, 361, 19*a^2 - 38*a + 38, -19) 1327 1420 """ 1328 1421 try: 1329 1422 return self.__factorization -
sage/rings/number_field/order.py
diff --git a/sage/rings/number_field/order.py b/sage/rings/number_field/order.py
a b 673 673 sage: P = K.ideal(61).factor()[0][0] 674 674 sage: OK = K.maximal_order() 675 675 sage: OK.residue_field(P) 676 Residue field in abar of Fractional ideal ( -2*a^2 +1)676 Residue field in abar of Fractional ideal (a^2 + 30, 61) 677 677 """ 678 678 if self.is_maximal(): 679 679 return self.number_field().residue_field(prime, name, check) -
sage/rings/number_field/small_primes_of_degree_one.py
diff --git a/sage/rings/number_field/small_primes_of_degree_one.py b/sage/rings/number_field/small_primes_of_degree_one.py
a b 46 46 EXAMPLES:: 47 47 48 48 sage: x = ZZ['x'].gen() 49 sage: F.<a> = NumberField(x^2 - 2 , 'a')49 sage: F.<a> = NumberField(x^2 - 2) 50 50 sage: Ps = F.primes_of_degree_one_list(3) 51 51 sage: Ps # random 52 52 [Fractional ideal (2*a + 1), Fractional ideal (-3*a + 1), Fractional ideal (-a + 5)] … … 59 59 60 60 The next two examples are for relative number fields.:: 61 61 62 sage: L.<b> = F.extension(x^3 - a , 'b')62 sage: L.<b> = F.extension(x^3 - a) 63 63 sage: Ps = L.primes_of_degree_one_list(3) 64 64 sage: Ps # random 65 65 [Fractional ideal (17, b - 5), Fractional ideal (23, b - 4), Fractional ideal (31, b - 2)] … … 69 69 True 70 70 sage: all(P.residue_class_degree() == 1 for P in Ps) 71 71 True 72 sage: M.<c> = NumberField(x^2 - x*b^2 + b , 'c')72 sage: M.<c> = NumberField(x^2 - x*b^2 + b) 73 73 sage: Ps = M.primes_of_degree_one_list(3) 74 74 sage: Ps # random 75 75 [Fractional ideal (17, c - 2), Fractional ideal (c - 1), Fractional ideal (41, c + 15)] -
sage/rings/polynomial/polynomial_quotient_ring.py
diff --git a/sage/rings/polynomial/polynomial_quotient_ring.py b/sage/rings/polynomial/polynomial_quotient_ring.py
a b 888 888 ((...1/3*a - 1)*b^2 + ...*b + ...*a + ..., +Infinity), 889 889 ((...1/3*a + 1)*b^2 ...*b ...*a ..., +Infinity)] 890 890 sage: L.S_units([K.ideal(1/2*a - 3/2)]) 891 [((...1/6*a - 1/2)*b^2 + (...1/3*a + 1)*b ... 2/3*a - 2, +Infinity), 892 (-1/2*a + 1/2, 6), 893 ((-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2, +Infinity), 894 ((...1/3*a ... 1)*b^2 + (...2/3*a - 2)*b + ...*a + ..., +Infinity)] 891 [(1/3*a*b^2 - 2/3*a*b + 4/3*a, +Infinity), (-1/2*a + 1/2, 6), 892 ((-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a + 1/2, +Infinity), 893 ((-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, +Infinity)] 895 894 sage: L.S_units([K.ideal(2)]) 896 [(( ...*a ... 1/2)*b^2 + (...a ... 1)*b + ...*a ...3/2, +Infinity),895 [((-1/2*a - 1/2)*b^2 + (a + 1)*b - 3/2*a - 3/2, +Infinity), 897 896 ((1/6*a + 1/2)*b^2 + (-1/3*a - 1)*b + 1/6*a + 3/2, +Infinity), 898 ((...*a + 1/2)*b^2 + (...a - 1)*b ...*a + ..., +Infinity), 899 (-1/2*a + 1/2, 6), 900 ((-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2, +Infinity), 901 ((-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, +Infinity)] 897 ((1/6*a + 1/2)*b^2 + (-1/3*a - 1)*b + 2/3*a + 1, +Infinity), 898 (-1/2*a + 1/2, 6), ((-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a + 1/2, +Infinity), 899 ((-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, +Infinity)] 902 900 903 901 Note that all the returned values live where we expect them to:: 904 902 … … 948 946 sage: L.<b> = K['y'].quotient(y^3 + 5); L 949 947 Univariate Quotient Polynomial Ring in b over Number Field in a with defining polynomial x^2 + 3 with modulus y^3 + 5 950 948 sage: L.units() 951 [(-1/2*a + 1/2, 6), 952 ((...1/3*a - 1)*b^2 + ...*b + ...*a + ..., +Infinity), 949 [(-1/2*a + 1/2, 6), (2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3, +Infinity), 953 950 ((-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2, +Infinity)] 954 951 sage: L.<b> = K.extension(y^3 + 5) 955 952 sage: L.unit_group() 956 953 Unit group with structure C6 x Z x Z of Number Field in b with defining polynomial x^3 + 5 over its base field 957 954 sage: L.unit_group().gens() 958 [-1/2*a + 1/2, 959 (...1/3*a - 1)*b^2 + ...*b + ...*a + ..., 960 (-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2] 955 [-1/2*a + 1/2, (1/3*a + 1)*b^2 + (-2/3*a - 2)*b + 4/3*a + 3, 956 (1/3*a + 1)*b^2 + (-2/3*a - 2)*b + 5/6*a + 7/2] 961 957 962 958 Note that all the returned values live where we expect them to:: 963 959 … … 1139 1135 sage: D.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1)], 3) 1140 1136 [2, -a - 1] 1141 1137 sage: D.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3) 1142 [2, -a - 1, -a]1138 [2, -a - 1, a] 1143 1139 1144 1140 """ 1145 1141 units, clgp_gens = self._S_class_group_and_units(tuple(S), proof=proof) -
sage/rings/residue_field.pyx
diff --git a/sage/rings/residue_field.pyx b/sage/rings/residue_field.pyx
a b 14 14 841 15 15 16 16 We reduce mod a prime for which the ring of integers is not 17 monogenic (i.e., 2 is an essential discriminant divisor): 17 monogenic (i.e., 2 is an essential discriminant divisor):: 18 18 19 sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8) 19 20 sage: F = K.factor(2); F 20 21 (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)) … … 25 26 sage: F[2][0].residue_field() 26 27 Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4) 27 28 28 We can also form residue fields from ZZ: 29 We can also form residue fields from ZZ:: 30 29 31 sage: ZZ.residue_field(17) 30 32 Residue field of Integers modulo 17 31 33 … … 35 37 -- John Cremona (2008-9): extend reduction maps to the whole valuation ring 36 38 add support for residue fields of ZZ 37 39 38 TESTS: 40 TESTS:: 41 39 42 sage: K.<z> = CyclotomicField(7) 40 43 sage: P = K.factor(17)[0][0] 41 44 sage: ff = K.residue_field(P) … … 43 46 sage: parent(a*a) 44 47 Residue field in zbar of Fractional ideal (17) 45 48 46 Reducing a curve modulo a prime: 49 Reducing a curve modulo a prime:: 50 47 51 sage: K.<s> = NumberField(x^2+23) 48 52 sage: OK = K.ring_of_integers() 49 53 sage: E = EllipticCurve([0,0,0,K(1),K(5)]) … … 52 56 sage: E.base_extend(Fpp) 53 57 Elliptic Curve defined by y^2 = x^3 + x + 5 over Residue field of Fractional ideal (13, s - 4) 54 58 55 Calculating Groebner bases over various residue fields. First over a small non-prime field: 59 Calculating Groebner bases over various residue fields. First over a small non-prime field:: 60 56 61 sage: F1.<u> = NumberField(x^6 + 6*x^5 + 124*x^4 + 452*x^3 + 4336*x^2 + 8200*x + 42316) 57 62 sage: reduct_id = F1.factor(47)[0][0] 58 63 sage: Rf = F1.residue_field(reduct_id) … … 63 68 sage: R.<X, Y> = PolynomialRing(Rf) 64 69 sage: ubar = Rf(u) 65 70 sage: I = ideal([ubar*X + Y]); I 66 Ideal ((ubar)*X + Y) of Multivariate Polynomial Ring in X, Y over Residue field in ubar of Fractional ideal ( 47, 517/55860*u^5 + 235/3724*u^4 + 9829/13965*u^3 + 54106/13965*u^2 + 64517/27930*u + 755696/13965)71 Ideal ((ubar)*X + Y) of Multivariate Polynomial Ring in X, Y over Residue field in ubar of Fractional ideal (u^3 - 22*u^2 - 9*u + 5, 47) 67 72 sage: I.groebner_basis() 68 73 [X + (-19*ubar^2 - 5*ubar - 17)*Y] 69 74 70 And now over a large prime field: 75 And now over a large prime field:: 76 71 77 sage: x = ZZ['x'].0 72 78 sage: F1.<u> = NumberField(x^2 + 6*x + 324) 73 79 sage: reduct_id = F1.prime_above(next_prime(2^42)) … … 125 131 of the ring of integers of a number field. 126 132 127 133 INPUT: 128 p -- a prime ideal of an order in a number field. 129 names -- the variable name for the finite field created. 130 Defaults to the name of the number field variable but 131 with bar placed after it. 132 check -- whether or not to check if p is prime. 134 135 - ``p`` -- a prime ideal of an order in a number field. 136 - ``names`` -- the variable name for the finite field created. 137 Defaults to the name of the number field variable but with 138 bar placed after it. 139 - ``check`` -- whether or not to check if p is prime. 133 140 134 141 OUTPUT: 135 -- The residue field at the prime p. 142 143 - The residue field at the prime p. 136 144 137 EXAMPLES: 145 EXAMPLES:: 146 138 147 sage: K.<a> = NumberField(x^3-7) 139 148 sage: P = K.ideal(29).factor()[0][0] 140 149 sage: ResidueField(P) 141 150 Residue field in abar of Fractional ideal (2*a^2 + 3*a - 10) 142 151 143 The result is cached: 152 The result is cached:: 153 144 154 sage: ResidueField(P) is ResidueField(P) 145 155 True 146 156 sage: k = K.residue_field(P); k … … 149 159 841 150 160 151 161 An example where the generator of the number field doesn't 152 generate the residue class field. 162 generate the residue class field:: 163 153 164 sage: K.<a> = NumberField(x^3-875) 154 165 sage: P = K.ideal(5).factor()[0][0]; k = K.residue_field(P); k 155 Residue field in abar of Fractional ideal ( 5, -2/25*a^2 - 1/5*a + 2)166 Residue field in abar of Fractional ideal (-2/25*a^2 - 1/5*a + 2, 5) 156 167 sage: k.polynomial() 157 168 abar^2 + 3*abar + 4 158 169 sage: k.0^3 - 875 159 170 2 160 171 161 An example where the residue class field is large but of degree 1: 172 An example where the residue class field is large but of degree 1:: 173 162 174 sage: K.<a> = NumberField(x^3-875); P = K.ideal(2007).factor()[0][0]; k = K.residue_field(P); k 163 Residue field of Fractional ideal ( -2/25*a^2 - 2/5*a -3)175 Residue field of Fractional ideal (a + 55, 223) 164 176 sage: k(a) 165 177 168 166 178 sage: k(a)^3 - 875 167 179 0 168 180 169 181 In this example, 2 is an inessential discriminant divisor, so divides 170 the index of ZZ[a] in the maximal order for all a. 182 the index of ZZ[a] in the maximal order for all a:: 183 171 184 sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P 172 185 Fractional ideal (1/2*a^2 - 1/2*a + 1) 173 186 sage: F = K.residue_field(P); F … … 288 301 """ 289 302 The class representing a generic residue field. 290 303 291 EXAMPLES: 304 EXAMPLES:: 305 292 306 sage: I = QQ[i].factor(2)[0][0]; I 293 307 Fractional ideal (I + 1) 294 308 sage: k = I.residue_field(); k … … 299 313 def __init__(self, p, f, intp): 300 314 """ 301 315 INPUT: 302 p -- the prime (ideal) defining this residue field 303 f -- the morphism from the order to self. 304 intp -- the rational prime that p lives over. 316 317 - ``p`` -- the prime (ideal) defining this residue field 318 - ``f`` -- the morphism from the order to self. 319 - ``intp`` -- the rational prime that p lives over. 305 320 306 321 EXAMPLES:: 307 322 … … 330 345 r""" 331 346 Return the maximal ideal that this residue field is the quotient by. 332 347 333 EXAMPLES: 348 EXAMPLES:: 349 334 350 sage: K.<a> = NumberField(x^3 + x + 1) 335 351 sage: P = K.ideal(29).factor()[0][0] 336 352 sage: k = K.residue_field(P) # indirect doctest … … 346 362 347 363 def coerce_map_from_impl(self, R): 348 364 """ 349 EXAMPLES: 365 EXAMPLES:: 366 350 367 sage: K.<i> = NumberField(x^2+1) 351 368 sage: P = K.ideal(-3*i-2) 352 369 sage: OK = K.maximal_order() … … 365 382 """ 366 383 Returns a string describing this residue field. 367 384 368 EXAMPLES: 385 EXAMPLES:: 386 369 387 sage: K.<a> = NumberField(x^3-7) 370 388 sage: P = K.ideal(29).factor()[0][0] 371 389 sage: k = K.residue_field(P) … … 384 402 Returns a lift of x to the Order, returning a "polynomial" in the 385 403 generator with coefficients between 0 and $p-1$. 386 404 387 EXAMPLES: 405 EXAMPLES:: 406 388 407 sage: K.<a> = NumberField(x^3-7) 389 408 sage: P = K.ideal(29).factor()[0][0] 390 409 sage: k =K.residue_field(P) … … 406 425 Return the partially defined reduction map from the number 407 426 field to this residue class field. 408 427 409 EXAMPLES: 428 EXAMPLES:: 429 410 430 sage: I = QQ[2^(1/3)].factor(2)[0][0]; I 411 431 Fractional ideal (-a) 412 432 sage: k = I.residue_field(); k … … 422 442 423 443 def lift_map(self): 424 444 """ 425 EXAMPLES: 445 EXAMPLES:: 446 426 447 sage: I = QQ[3^(1/3)].factor(5)[1][0]; I 427 448 Fractional ideal (-a + 2) 428 449 sage: k = I.residue_field(); k … … 443 464 Compares two residue fields: they are equal iff the primes 444 465 defining them are equal. 445 466 446 EXAMPLES: 467 EXAMPLES:: 468 447 469 sage: K.<a> = NumberField(x^3-11) 448 470 sage: F = K.ideal(37).factor(); F 449 471 (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5)) * (Fractional ideal (37, a + 9)) … … 463 485 r""" 464 486 Return the hash of self. 465 487 466 EXAMPLES: 488 EXAMPLES:: 489 467 490 sage: K.<a> = NumberField(x^3 + x + 1) 468 491 sage: hash(K.residue_field(K.prime_above(17))) # random 469 492 -6463132282686559142 … … 477 500 A reduction map from a (subset) of a number field to this residue 478 501 class field. 479 502 480 EXAMPLES: 503 EXAMPLES:: 504 481 505 sage: I = QQ[sqrt(17)].factor(5)[0][0]; I 482 506 Fractional ideal (5) 483 507 sage: k = I.residue_field(); k … … 489 513 """ 490 514 Create a reduction map. 491 515 492 EXAMPLES: 516 EXAMPLES:: 517 493 518 sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8) 494 519 sage: F = K.factor(2)[0][0].residue_field() 495 520 sage: F.reduction_map() … … 504 529 """ 505 530 Return the domain of this reduction map. 506 531 507 EXAMPLES: 532 EXAMPLES:: 533 508 534 sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 32) 509 535 sage: F = K.factor(2)[0][0].residue_field() 510 536 sage: F.reduction_map().domain() … … 516 542 """ 517 543 Return the codomain of this reduction map. 518 544 519 EXAMPLES: 545 EXAMPLES:: 546 520 547 sage: K.<a> = NumberField(x^3 + 128) 521 548 sage: F = K.factor(2)[0][0].residue_field() 522 549 sage: F.reduction_map().codomain() … … 531 558 If x doesn't map because it has negative valuation, then a 532 559 ZeroDivisionError exception is raised. 533 560 534 EXAMPLES: 561 EXAMPLES:: 562 535 563 sage: K.<a> = NumberField(x^2 + 1) 536 564 sage: F = K.factor(2)[0][0].residue_field() 537 565 sage: r = F.reduction_map(); r … … 544 572 ZeroDivisionError: Cannot reduce field element 1/2*a modulo Fractional ideal (a + 1): it has negative valuation 545 573 546 574 An example to show that the issue raised in trac \#1951 547 has been fixed. 575 has been fixed:: 576 548 577 sage: K.<i> = NumberField(x^2 + 1) 549 578 sage: P1, P2 = [g[0] for g in K.factor(5)]; (P1,P2) 550 579 (Fractional ideal (-i - 2), Fractional ideal (2*i + 1)) … … 562 591 -1 563 592 sage: F2(a) 564 593 Traceback (most recent call last): 594 ... 565 595 ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (2*i + 1): it has negative valuation 566 567 596 """ 568 597 # The reduction map is just x |--> F(to_vs(x) * (PB**(-1))) if 569 598 # either x is integral or the denominator of x is coprime to … … 578 607 except ZeroDivisionError: 579 608 raise ZeroDivisionError, "Cannot reduce rational %s modulo %s: it has negative valuation"%(x,p) 580 609 581 dx = x.denominator() 582 if x.is_integral() or dx.gcd(ZZ(p.absolute_norm())) == 1: 610 try: 583 611 return self.__F(self.__to_vs(x) * self.__PBinv) 612 except: pass 584 613 585 614 # Now we do have to work harder...below this point we handle 586 615 # cases which failed before trac 1951 was fixed. 587 616 R = self.__K.ring_of_integers() 588 dx = R( dx)617 dx = R(x.denominator()) 589 618 nx = R(dx*x) 590 619 vnx = nx.valuation(p) 591 620 vdx = dx.valuation(p) … … 593 622 return self(0) 594 623 if vnx < vdx: 595 624 raise ZeroDivisionError, "Cannot reduce field element %s modulo %s: it has negative valuation"%(x,p) 625 596 626 a = self.__K.uniformizer(p,'negative') ** vnx 597 627 nx /= a 598 628 dx /= a … … 609 639 610 640 def __repr__(self): 611 641 """ 612 EXAMPLES: 642 EXAMPLES:: 643 613 644 sage: K.<theta_5> = CyclotomicField(5) 614 645 sage: F = K.factor(7)[0][0].residue_field() 615 646 sage: F.reduction_map().__repr__() … … 621 652 """ 622 653 Lifting map from residue class field to number field. 623 654 624 EXAMPLES: 655 EXAMPLES:: 656 625 657 sage: K.<a> = NumberField(x^3 + 2) 626 658 sage: F = K.factor(5)[0][0].residue_field() 627 659 sage: F.degree() … … 637 669 """ 638 670 Create a lifting map. 639 671 640 EXAMPLES: 672 EXAMPLES:: 673 641 674 sage: K.<theta_5> = CyclotomicField(5) 642 675 sage: F = K.factor(7)[0][0].residue_field() 643 676 sage: F.lift_map() … … 666 699 """ 667 700 Return the codomain of this lifting map. 668 701 669 EXAMPLES: 702 EXAMPLES:: 703 670 704 sage: K.<a> = CyclotomicField(7) 671 705 sage: F = K.factor(5)[0][0].residue_field() 672 706 sage: L = F.lift_map(); L … … 680 714 """ 681 715 Lift from this residue class field to the number field. 682 716 683 EXAMPLES: 717 EXAMPLES:: 718 684 719 sage: K.<a> = CyclotomicField(7) 685 720 sage: F = K.factor(5)[0][0].residue_field() 686 721 sage: L = F.lift_map(); L … … 700 735 701 736 def __repr__(self): 702 737 """ 703 EXAMPLES: 738 EXAMPLES:: 739 704 740 sage: K.<theta_12> = CyclotomicField(12) 705 741 sage: F.<tmod> = K.factor(7)[0][0].residue_field() 706 742 sage: F.lift_map().__repr__() … … 716 752 The class representing a homomorphism from the order of a number 717 753 field to the residue field at a given prime. 718 754 719 EXAMPLES: 755 EXAMPLES:: 756 720 757 sage: K.<a> = NumberField(x^3-7) 721 758 sage: P = K.ideal(29).factor()[0][0] 722 759 sage: k = K.residue_field(P) … … 738 775 im_gen -- The image of the generator of the number field. 739 776 740 777 EXAMPLES: 741 We create a residue field homomorphism: 778 779 We create a residue field homomorphism:: 780 742 781 sage: K.<theta> = CyclotomicField(5) 743 782 sage: P = K.factor(7)[0][0] 744 783 sage: P.residue_class_degree() … … 759 798 760 799 cpdef Element _call_(self, x): 761 800 """ 762 Applies this morphism to an element 801 Applies this morphism to an element. 763 802 764 EXAMPLES: 803 EXAMPLES:: 804 765 805 sage: K.<a> = NumberField(x^3-x+8) 766 806 sage: P = K.ideal(29).factor()[0][0] 767 807 sage: k =K.residue_field(P) … … 779 819 Returns a lift of x to the Order, returning a "polynomial" in 780 820 the generator with coefficients between 0 and p-1. 781 821 782 EXAMPLES: 822 EXAMPLES:: 823 783 824 sage: K.<a> = NumberField(x^3-7) 784 825 sage: P = K.ideal(29).factor()[0][0] 785 826 sage: k = K.residue_field(P) … … 804 845 """ 805 846 The class representing residue fields of number fields that have prime order. 806 847 807 EXAMPLES: 848 EXAMPLES:: 849 808 850 sage: R.<x> = QQ[] 809 851 sage: K.<a> = NumberField(x^3-7) 810 852 sage: P = K.ideal(29).factor()[1][0] … … 828 870 def __init__(self, p, name, im_gen = None, intp = None): 829 871 """ 830 872 INPUT: 831 p -- A prime ideal of a number field. 832 name -- the name of the generator of this extension 833 im_gen -- the image of the generator of the number field in this finite field. 834 intp -- the rational prime that p lies over. 873 874 - ``p`` -- A prime ideal of a number field. 875 - ``name`` -- the name of the generator of this extension 876 - ``im_gen`` -- the image of the generator of the number field in this finite field. 877 - ``intp`` -- the rational prime that p lies over. 835 878 836 EXAMPLES: 879 EXAMPLES:: 880 837 881 sage: K.<i> = QuadraticField(-1) 838 882 sage: kk = ResidueField(K.factor(5)[0][0]) 839 883 sage: type(kk) … … 851 895 def __call__(self, x): 852 896 """ 853 897 INPUT: 854 x -- something to cast in to self. 898 899 - ``x`` -- something to cast in to self. 855 900 856 EXAMPLES: 901 EXAMPLES:: 902 857 903 sage: R.<x> = QQ[] 858 904 sage: K.<a> = NumberField(x^3-7) 859 905 sage: P = K.ideal(29).factor()[1][0] … … 881 927 """ 882 928 The class representing residue fields of number fields that have non-prime order >= 2^16. 883 929 884 EXAMPLES: 930 EXAMPLES:: 931 885 932 sage: K.<a> = NumberField(x^3-7) 886 933 sage: P = K.ideal(923478923).factor()[0][0] 887 934 sage: k = K.residue_field(P) … … 897 944 """ 898 945 def __init__(self, p, q, name, g, intp): 899 946 """ 900 EXAMPLES: 901 We create an ext_pari residue field: 947 EXAMPLES:: 948 949 We create an ext_pari residue field:: 950 902 951 sage: K.<a> = NumberField(x^3-7) 903 952 sage: P = K.ideal(923478923).factor()[0][0] 904 953 sage: type(P.residue_field()) … … 913 962 """ 914 963 Coerce x into self. 915 964 916 EXAMPLES: 965 EXAMPLES:: 966 917 967 sage: K.<aa> = NumberField(x^3 - 2) 918 968 sage: P = K.factor(10007)[0][0] 919 969 sage: P.residue_class_degree() … … 940 990 """ 941 991 The class representing residue fields of number fields that have non-prime order < 2**16. 942 992 943 EXAMPLES: 993 EXAMPLES:: 994 944 995 sage: R.<x> = QQ[] 945 996 sage: K.<a> = NumberField(x^3-7) 946 997 sage: P = K.ideal(29).factor()[0][0] … … 958 1009 def __init__(self, p, q, name, g, intp): 959 1010 """ 960 1011 INPUT: 961 p -- the prime ideal defining this residue field 962 q -- the order of this residue field (a power of intp) 963 name -- the name of the generator of this extension 964 g -- the polynomial modulus for this extension 965 intp -- the rational prime that p lies over. 1012 1013 - ``p`` -- the prime ideal defining this residue field 1014 - ``q`` -- the order of this residue field (a power of intp) 1015 - ``name`` -- the name of the generator of this extension 1016 - ``g`` -- the polynomial modulus for this extension 1017 - ``intp`` -- the rational prime that p lies over. 966 1018 967 EXAMPLES: 1019 EXAMPLES:: 1020 968 1021 sage: R.<x> = QQ[] 969 1022 sage: K.<a> = NumberField(x^4+3*x^2-17) 970 1023 sage: P = K.ideal(61).factor()[0][0] … … 978 1031 def __call__(self, x): 979 1032 """ 980 1033 INPUT: 981 x -- Something to cast into self. 1034 1035 - x -- Something to cast into self. 982 1036 983 EXAMPLES: 1037 EXAMPLES:: 1038 984 1039 sage: R.<x> = QQ[] 985 1040 sage: K.<a> = NumberField(x^4+3*x^2-17) 986 1041 sage: P = K.ideal(61).factor()[0][0]