# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1197632483 28800
# Node ID 77b659019e2f7a7c940012f278683c0214ab3806
# Parent 10855f8c76c12b6ccc037fb4bb9b801b74f06c27
Trac #1183 -- More work on residue class fields. (not done yet)
diff -r 10855f8c76c1 -r 77b659019e2f sage/modules/quotient_module.py
a
|
b
|
class FreeModule_ambient_field_quotient( |
173 | 173 | |
174 | 174 | An element coerces in if it can be coerced into V, or if not at least if |
175 | 175 | if it can be made sense of as a list of length the dimension of self. |
176 | | |
177 | | |
| 176 | |
178 | 177 | EXAMPLES: |
179 | 178 | We create a 2-dimensional quotient of a 3-dimension ambient vector space. |
180 | 179 | sage: M = QQ^3 / [[1,2,3]] |
… |
… |
class FreeModule_ambient_field_quotient( |
193 | 192 | (1, 2) |
194 | 193 | """ |
195 | 194 | try: |
196 | | return self._coerce_impl(x) |
197 | | except TypeError: |
| 195 | if x.parent() is self: |
| 196 | return x |
| 197 | except AttributeError: |
198 | 198 | pass |
199 | 199 | try: |
200 | 200 | return FreeModule_ambient_field.__call__(self, x) |
diff -r 10855f8c76c1 -r 77b659019e2f sage/rings/residue_field.pyx
a
|
b
|
from sage.rings.polynomial.polynomial_ri |
55 | 55 | |
56 | 56 | residue_field_cache = {} |
57 | 57 | |
58 | | def ResidueField(p, names = None, check = True): |
| 58 | def ResidueField(p, names = None, check = True, trygen=False): |
59 | 59 | """ |
60 | 60 | A function that returns the residue class field of a prime ideal p |
61 | 61 | of the ring of integers of a number field. |
62 | 62 | |
63 | 63 | INPUT: |
64 | | p -- a prime integer or prime ideal of an order in a number |
65 | | field. |
| 64 | p -- a prime ideal of an order in a number field. |
66 | 65 | names -- the variable name for the finite field created. |
67 | 66 | Defaults to the name of the number field variable but |
68 | 67 | with bar placed after it. |
… |
… |
def ResidueField(p, names = None, check |
76 | 75 | sage: P = K.ideal(29).factor()[0][0] |
77 | 76 | sage: ResidueField(P) |
78 | 77 | Residue field in abar of Fractional ideal (2*a^2 + 3*a - 10) |
| 78 | |
| 79 | The result is cached: |
| 80 | sage: ResidueField(P) is ResidueField(P) |
| 81 | True |
79 | 82 | sage: k = K.residue_field(P); k |
80 | 83 | Residue field in abar of Fractional ideal (2*a^2 + 3*a - 10) |
81 | 84 | sage: k.order() |
… |
… |
def ResidueField(p, names = None, check |
123 | 126 | names = str(names[0]) |
124 | 127 | else: |
125 | 128 | names = None |
126 | | key = (p, names) |
| 129 | key = (p, names, trygen) |
127 | 130 | if residue_field_cache.has_key(key): |
128 | 131 | k = residue_field_cache[key]() |
129 | 132 | if k is not None: |
… |
… |
def ResidueField(p, names = None, check |
148 | 151 | n = p.residue_class_degree() |
149 | 152 | gen_ok = False |
150 | 153 | from sage.matrix.constructor import matrix |
151 | | try: |
152 | | x = K.gen() |
153 | | M = matrix(k, n+1, n, [to_vs(x**i).list() for i in range(n+1)]) |
154 | | W = M.transpose().echelon_form() |
155 | | if M.rank() == n: |
156 | | PB = M.matrix_from_rows(range(n)) |
157 | | gen_ok = True |
158 | | f = R((-W.column(n)).list() + [1]) |
159 | | except TypeError: |
160 | | pass |
| 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 |
161 | 167 | if not gen_ok: |
162 | 168 | bad = True |
163 | 169 | for u in U: # using this iterator may not be optimal, we may get a long string of non-generators |
… |
… |
class ResidueFiniteField_prime_modn(Resi |
419 | 425 | intp -- the rational prime that p lies over. |
420 | 426 | |
421 | 427 | EXAMPLES: |
422 | | sage: k = ResidueField(17); k |
423 | | Residue field of 17 |
424 | | sage: type(k) |
425 | | <class 'sage.rings.residue_field.ResidueFiniteField_prime_modn'> |
| 428 | sage: K.<i> = QuadraticField(-1) |
| 429 | sage: kk = ResidueField(K.factor_integer(5)[0][0]) |
| 430 | sage: type(kk) |
| 431 | <class 'sage.rings.residue_field.ResidueFiniteField_prime_modn'> |
426 | 432 | """ |
427 | 433 | self.p = p # Here because we have to create a NFResidueFieldHomomorphism before calling ResidueField_generic.__init__(self,...) |
428 | 434 | if im_gen is None: |