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 b  
    323323        2
    324324
    325325    The following demonstrate coercions for finite fields using Conway
    326     or pseudo-Conway polynomials::
     326    polynomials::
    327327
    328328        sage: k = GF(5^2, conway=True, prefix='z'); a = k.gen()
    329329        sage: l = GF(5^5, conway=True, prefix='z'); b = l.gen()
     
    386386                # implemented in Sage.  It requires the user to
    387387                # specify two parameters:
    388388                #
    389                 # - `conway` -- either True or PseudoConwayPolyTree;
    390                 #   if True, a PseudoConwayPolyTree is generated
    391                 #   automatically.
     389                # - `conway` -- boolean; if True, this field is
     390                #   constructed to fit in a compatible system using
     391                #   a Conway polynomial.
    392392                # - `prefix` -- a string used to generate names for
    393393                #   automatically constructed finite fields
    394394                #
     
    402402                #     sage: F, e = Fpbar.subfield(3)  # e is the embedding into Fpbar
    403403                #     sage: F
    404404                #     Finite field in z3 of size 5^3
     405                #
     406                # This temporary solution only uses actual Conway
     407                # polynomials (no pseudo-Conway polynomials), since
     408                # pseudo-Conway polynomials are not unique, and until
     409                # we have algebraic closures of finite fields, there
     410                # is no good place to store a specific choice of
     411                # pseudo-Conway polynomials.
    405412                if name is None:
    406413                    if not (kwds.has_key('conway') and kwds['conway']):
    407414                        raise ValueError("parameter 'conway' is required if no name given")
     
    410417                    name = kwds['prefix'] + str(n)
    411418
    412419                if kwds.has_key('conway') and kwds['conway']:
    413                     from conway_polynomials import PseudoConwayPolyTree, find_pseudo_conway_polynomial_tree
    414                     pcpt = kwds['conway']
    415                     if (isinstance(pcpt, PseudoConwayPolyTree)
    416                         and pcpt.p == p and pcpt.n == n):
    417                         pass
    418                     elif pcpt is True:
    419                         pcpt = find_pseudo_conway_polynomial_tree(p, n)
    420                     else:
    421                         raise ValueError("invalid value for parameter 'conway'")
     420                    from conway_polynomials import conway_polynomial
    422421                    if not kwds.has_key('prefix'):
    423                         raise ValueError("a prefix must be specified for finite fields defined by Conway polynomials")
     422                        raise ValueError("a prefix must be specified if conway=True")
    424423                    if modulus is not None:
    425                         raise ValueError("no modulus may be specified for finite fields defined by Conway polynomials")
    426                     # Always use the polynomial specified by pcpt.
    427                     modulus = pcpt.f
    428                     # We do not store `pcpt` in the finite field, so
    429                     # that we will not be forced in the future to
    430                     # recognise it for unpickling.  The pseudo-Conway
    431                     # polynomial tree is currently cached by the code
    432                     # in conway_polynomials.py, and should be cached
    433                     # in Fpbar in the future.
     424                        raise ValueError("no modulus may be specified if conway=True")
     425                    # The following raises a RuntimeError if no polynomial is found.
     426                    modulus = conway_polynomial(p, n)
    434427
    435428                if modulus is None or isinstance(modulus, str):
    436429                    # A string specifies an algorithm to find a suitable modulus.