# Ticket #1183: trac-1183-step5.patch

File trac-1183-step5.patch, 4.6 KB (added by was, 15 years ago)
• ## sage/modules/quotient_module.py

```# 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 class FreeModule_ambient_field_quotient( An element coerces in if it can be coerced into V, or if not at least if if it can be made sense of as a list of length the dimension of self. EXAMPLES: We create a 2-dimensional quotient of a 3-dimension ambient vector space. sage: M = QQ^3 / [[1,2,3]] class FreeModule_ambient_field_quotient( (1, 2) """ try: return self._coerce_impl(x) except TypeError: if x.parent() is self: return x except AttributeError: pass try: return FreeModule_ambient_field.__call__(self, x)
• ## sage/rings/residue_field.pyx

`diff -r 10855f8c76c1 -r 77b659019e2f sage/rings/residue_field.pyx`
 a from sage.rings.polynomial.polynomial_ri residue_field_cache = {} def ResidueField(p, names = None, check = True): def ResidueField(p, names = None, check = True, trygen=False): """ A function that returns the residue class field of a prime ideal p of the ring of integers of a number field. INPUT: p -- a prime integer or prime ideal of an order in a number field. p -- a prime ideal of an order in a number field. names -- the variable name for the finite field created. Defaults to the name of the number field variable but with bar placed after it. def ResidueField(p, names = None, check sage: P = K.ideal(29).factor()[0][0] sage: ResidueField(P) Residue field in abar of Fractional ideal (2*a^2 + 3*a - 10) The result is cached: sage: ResidueField(P) is ResidueField(P) True sage: k = K.residue_field(P); k Residue field in abar of Fractional ideal (2*a^2 + 3*a - 10) sage: k.order() def ResidueField(p, names = None, check names = str(names[0]) else: names = None key = (p, names) key = (p, names, trygen) if residue_field_cache.has_key(key): k = residue_field_cache[key]() if k is not None: def ResidueField(p, names = None, check n = p.residue_class_degree() gen_ok = False from sage.matrix.constructor import matrix try: x = K.gen() M = matrix(k, n+1, n, [to_vs(x**i).list() for i in range(n+1)]) W = M.transpose().echelon_form() if M.rank() == n: PB = M.matrix_from_rows(range(n)) gen_ok = True f = R((-W.column(n)).list() + [1]) except TypeError: pass if trygen: # This optimization not ready yet. try: x = K.gen() M = matrix(k, n+1, n, [to_vs(x**i).list() for i in range(n+1)]) print M W = M.transpose().echelon_form() if M.rank() == n: PB = M.matrix_from_rows(range(n)) gen_ok = True f = R((-W.column(n)).list() + [1]) except (TypeError, ZeroDivisionError): pass if not gen_ok: bad = True 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 intp -- the rational prime that p lies over. EXAMPLES: sage: k = ResidueField(17); k Residue field of 17 sage: type(k) sage: K. = QuadraticField(-1) sage: kk = ResidueField(K.factor_integer(5)[0][0]) sage: type(kk) """ self.p = p # Here because we have to create a NFResidueFieldHomomorphism before calling ResidueField_generic.__init__(self,...) if im_gen is None: