Ticket #13400: trac_13400_quick_ZZ_ideal.patch

File trac_13400_quick_ZZ_ideal.patch, 2.1 KB (added by SimonKing, 7 years ago)

Provide a short-cut for the creation of ideals in ZZ

  • sage/rings/finite_rings/integer_mod_ring.py

    # HG changeset patch
    # User Simon King <simon.king@uni-jena.de>
    # Date 1346018515 -7200
    # Node ID 3ef29cf2e57d361b618aed79ba69a24c46956c18
    # Parent  e122550648872290ee7ff51dbbeb2e726cfbd9cb
    #13400: Provide a short-cut for the creation of ideals in ZZ
    
    diff --git a/sage/rings/finite_rings/integer_mod_ring.py b/sage/rings/finite_rings/integer_mod_ring.py
    a b  
    176176from sage.categories.category import JoinCategory
    177177default_category = JoinCategory((CommutativeRings(), FiniteEnumeratedSets()))
    178178ZZ = integer_ring.IntegerRing()
     179quick_ZZ_ideal = integer_ring.QuickZZIdealCreator(ZZ)
    179180
    180181strong_references = [] # If the elements are cached, then the ring itself, too.
    181182
     
    324325        # name 'x' is used because it's also used for the ring of
    325326        # integers: see the __init__ method for IntegerRing_class in
    326327        # sage/rings/integer_ring.pyx.
    327         quotient_ring.QuotientRing_generic.__init__(self, ZZ, ZZ.ideal(order),
     328        quotient_ring.QuotientRing_generic.__init__(self, ZZ, quick_ZZ_ideal(order),
    328329                                                    names=('x',),
    329330                                                    category=category)
    330331        # Calling ParentWithGens is not needed, the job is done in
  • sage/rings/integer_ring.pyx

    diff --git a/sage/rings/integer_ring.pyx b/sage/rings/integer_ring.pyx
    a b  
    10521052ZZ = IntegerRing_class()
    10531053Z = ZZ
    10541054
     1055# A quick and dirty way of constructing ideals, to be used in the generation of
     1056# finite fields
     1057from sage.rings.ideal import Ideal_pid
     1058from sage.structure.element cimport Element
     1059
     1060cdef class QuickZZIdealCreator:
     1061    cdef Parent I_monoid
     1062    cdef Parent Z
     1063    def __init__(self, Z):
     1064        self.Z = Z
     1065        self.I_monoid = Z.ideal_monoid()
     1066    def __call__(self, m):
     1067        out = <type>Ideal_pid.__new__(Ideal_pid)
     1068        out._Ideal_generic__ring = self.Z
     1069        out._Ideal_generic__gens = (m,)
     1070        (<Element>out)._parent = self.I_monoid
     1071        return out
     1072
    10551073def IntegerRing():
    10561074    """
    10571075    Return the integer ring