Ticket #9054: trac_9054-invert_ideal.patch

File trac_9054-invert_ideal.patch, 1.9 KB (added by mderickx, 6 years ago)
  • sage/rings/function_field/function_field_ideal.py

    # HG changeset patch
    # User Maarten Derickx <m.derickx.student@gmail.com>
    # Date 1316031695 -7200
    # Node ID 6f8e65667825ffd0345261f51cfa3dce2dc131cc
    # Parent  153bb398098fc3436dd120f465b9533a52d9a3ff
    #9054 fix jullians last comment
    
    diff --git a/sage/rings/function_field/function_field_ideal.py b/sage/rings/function_field/function_field_ideal.py
    a b  
    11from sage.rings.ideal import Ideal_generic
    2 
     2from sage.modules import free_module_element
    33class FunctionFieldIdeal(Ideal_generic):
    44    """
    55    A fractional ideal of a function field.
     
    228228        sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
    229229        sage: sage.rings.function_field.function_field_ideal.ideal_with_gens_over_base(M, [x^3+1,-y])
    230230        Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1   
     231   
     232    TESTS::
     233        sage: K.<x> = FunctionField(QQ)
     234        sage: O = K.maximal_order()
     235        sage: I = O*x
     236        sage: ~I
     237        Ideal (1/x) of Maximal order in Rational function field in x over Rational Field
     238        sage: ~I == O.ideal(1/x)
     239        True
     240   
    231241    """
    232242    K = R.fraction_field()
    233243    V, from_V, to_V = K.vector_space()
     
    238248    import function_field_order
    239249    if isinstance(R, function_field_order.FunctionFieldOrder_rational):
    240250        try:
    241             v = R._ring.ideal([x.element() for x in gens]).gens_reduced()
     251            gens = free_module_element.vector(x.element() for x in gens)
     252            d = gens.denominator()
     253            gens *= d
     254            v = R._ring.ideal(gens.list()).gens_reduced()
    242255            assert len(v) == 1
    243             basis = [to_V(v[0])]
     256            basis = [to_V(v[0]/d)]
    244257            M = V.span_of_basis(basis, check=False, already_echelonized=True, base_ring=R)
    245258        except Exception, msg:
    246259            print msg   # TODO --for debugging