# Ticket #8335: trac_8335-no_pseudo.patch

File trac_8335-no_pseudo.patch, 4.1 KB (added by pbruin, 8 years ago)

use only (non-pseudo-)Conway polynomials

• ## sage/rings/finite_rings/constructor.py

# HG changeset patch
# User Peter Bruin <peter.bruin@math.uzh.ch>
# Date 1375194667 -7200
# Node ID 52d88ed1b9d8254f09ae423640b8f4bf9bc87065
# Parent  31168f677375b917a402e34018a67194c618d86b
Use only (non-pseudo-)Conway polynomials for compatible finite fields

diff --git a/sage/rings/finite_rings/constructor.py b/sage/rings/finite_rings/constructor.py
 a 2 The following demonstrate coercions for finite fields using Conway or pseudo-Conway polynomials:: polynomials:: sage: k = GF(5^2, conway=True, prefix='z'); a = k.gen() sage: l = GF(5^5, conway=True, prefix='z'); b = l.gen() # implemented in Sage.  It requires the user to # specify two parameters: # # - `conway` -- either True or PseudoConwayPolyTree; #   if True, a PseudoConwayPolyTree is generated #   automatically. # - `conway` -- boolean; if True, this field is #   constructed to fit in a compatible system using #   a Conway polynomial. # - `prefix` -- a string used to generate names for #   automatically constructed finite fields # #     sage: F, e = Fpbar.subfield(3)  # e is the embedding into Fpbar #     sage: F #     Finite field in z3 of size 5^3 # # This temporary solution only uses actual Conway # polynomials (no pseudo-Conway polynomials), since # pseudo-Conway polynomials are not unique, and until # we have algebraic closures of finite fields, there # is no good place to store a specific choice of # pseudo-Conway polynomials. if name is None: if not (kwds.has_key('conway') and kwds['conway']): raise ValueError("parameter 'conway' is required if no name given") name = kwds['prefix'] + str(n) if kwds.has_key('conway') and kwds['conway']: from conway_polynomials import PseudoConwayPolyTree, find_pseudo_conway_polynomial_tree pcpt = kwds['conway'] if (isinstance(pcpt, PseudoConwayPolyTree) and pcpt.p == p and pcpt.n == n): pass elif pcpt is True: pcpt = find_pseudo_conway_polynomial_tree(p, n) else: raise ValueError("invalid value for parameter 'conway'") from conway_polynomials import conway_polynomial if not kwds.has_key('prefix'): raise ValueError("a prefix must be specified for finite fields defined by Conway polynomials") raise ValueError("a prefix must be specified if conway=True") if modulus is not None: raise ValueError("no modulus may be specified for finite fields defined by Conway polynomials") # Always use the polynomial specified by pcpt. modulus = pcpt.f # We do not store `pcpt` in the finite field, so # that we will not be forced in the future to # recognise it for unpickling.  The pseudo-Conway # polynomial tree is currently cached by the code # in conway_polynomials.py, and should be cached # in Fpbar in the future. raise ValueError("no modulus may be specified if conway=True") # The following raises a RuntimeError if no polynomial is found. modulus = conway_polynomial(p, n) if modulus is None or isinstance(modulus, str): # A string specifies an algorithm to find a suitable modulus.