Ticket #9054: trac_9054-part9.patch

File trac_9054-part9.patch, 5.7 KB (added by was, 8 years ago)

inverses of fractional ideals

  • sage/matrix/matrix2.pyx

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1275034943 25200
    # Node ID e939d56d831b78429f2c72a707d0a1c27c6fd6ca
    # Parent  10779925917f5495f8676539c674099bc6eef9c2
    trac 9054 (part 9): inverses of fractional ideals; hermite form for general matrices; some little function field bugfixes.
    
    diff -r 10779925917f -r e939d56d831b sage/matrix/matrix2.pyx
    a b  
    67716771        dp, up, vp = _smith_diag(d)
    67726772        return dp,up*u,v*vp
    67736773
     6774    def hermite_form(self, include_zero_rows=True, transformation=False):
     6775        """
     6776        Return the Hermite form of self, if it is defined.
     6777
     6778        INPUT:
     6779
     6780            - ``include_zero_rows`` -- bool (default: True); if False
     6781              the zero rows in the output matrix are deleted.
     6782
     6783            - ``transformation`` -- bool (default: False) a matrix U such that U*self == H.
     6784
     6785        OUTPUT:
     6786
     6787            - matrix H
     6788            - (optional) transformation matrix U such that U*self == H, possibly with zero
     6789              rows deleted...
     6790       
     6791
     6792        EXAMPLES::
     6793
     6794            sage: M = FunctionField(GF(7),'x').maximal_order()
     6795            sage: K.<x> = FunctionField(GF(7)); M = K.maximal_order()
     6796            sage: A = matrix(M, 2, 3, [x, 1, 2*x, x, 1+x, 2])
     6797            sage: A.hermite_form()
     6798            [      x       1     2*x]
     6799            [      0       x 5*x + 2]
     6800            sage: A.hermite_form(transformation=True)
     6801            (
     6802            [      x       1     2*x]  [1 0]
     6803            [      0       x 5*x + 2], [6 1]
     6804            )
     6805            sage: A = matrix(M, 2, 3, [x, 1, 2*x, 2*x, 2, 4*x])
     6806            sage: A.hermite_form(transformation=True, include_zero_rows=False)
     6807            ([  x   1 2*x], [1 0])
     6808            sage: H, U = A.hermite_form(transformation=True, include_zero_rows=True); H, U
     6809            (
     6810            [  x   1 2*x]  [1 0]
     6811            [  0   0   0], [5 1]
     6812            )
     6813            sage: U*A == H
     6814            True
     6815            sage: H, U = A.hermite_form(transformation=True, include_zero_rows=False)
     6816            sage: U*A
     6817            [  x   1 2*x]
     6818            sage: U*A == H
     6819            True
     6820        """
     6821        left, H, pivots = self._echelon_form_PID()
     6822        if not include_zero_rows:
     6823            i = H.nrows() - 1
     6824            while H.row(i) == 0:
     6825                i -= 1
     6826            H = H[:i+1]
     6827            if transformation:
     6828                left = left[:i+1]
     6829        if transformation:
     6830            return H, left
     6831        else:
     6832            return H
     6833
    67746834    def _echelon_form_PID(self):
    67756835        r"""
    67766836        Return a triple (left, a, pivots) where left*self == a and a is row
  • sage/rings/function_field/function_field_ideal.py

    diff -r 10779925917f -r e939d56d831b sage/rings/function_field/function_field_ideal.py
    a b  
    174174    def __invert__(self):
    175175        """
    176176        Return the inverse of this fractional ideal.
     177
     178        EXAMPLES::
     179
     180            sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
     181            sage: L.<y> = R.extension(y^2 - x^3 - 1); M = L.equation_order()   
     182            sage: I = M.ideal(y)
     183            sage: I.__invert__()
     184            Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
     185            sage: I^(-1)
     186            Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
     187            sage: I.__invert__() * I
     188            Ideal (1, 6*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
    177189        """
    178         # If I is this fractional ideal, then the inverse
    179         # of I is the set of elements x such that x*I is
    180         # in the unit ideal.  Our straightforward algorithm to
    181         # compute this is to take the homomorphism defined
    182         # by multiplication by generators of self, and compute
    183         # the inverse image something under it.
     190        if len(self.gens()) == 0:
     191            raise ZeroDivisionError
     192
     193        # NOTE: If  I = (g0, ..., gn), then {x : x*I is in R}
     194        # is the intersection over i of {x : x*gi is in R}
     195        # Thus (I + J)^(-1) = I^(-1) intersect J^(-1).
    184196       
    185        
     197        G = self.gens()
     198        R = self.ring()
     199        inv = R.ideal(~G[0])
     200        for g in G[1:]:
     201            inv = inv.intersection(R.ideal(~g))
     202        return inv
    186203
    187204def ideal_with_gens(R, gens):
    188205    """
     
    196213        sage: sage.rings.function_field.function_field_ideal.ideal_with_gens(M, [y])
    197214        Ideal (x^3 + 1, -y) of Order in Function field in y defined by y^2 - x^3 - 1
    198215    """
    199     return ideal_with_gens_over_base(R, [b*g for b in R.basis() for g in gens])
     216    K = R.fraction_field()
     217    return ideal_with_gens_over_base(R, [b*K(g) for b in R.basis() for g in gens])
    200218   
    201219
    202220def ideal_with_gens_over_base(R, gens):
  • sage/rings/function_field/todo.txt

    diff -r 10779925917f -r e939d56d831b sage/rings/function_field/todo.txt
    a b  
    11TODO:
    22
    3 [x] factor for elements of the rational function field
    4 
    5 [ ] ideals
    63[ ] isomorphisms between function fields:
    74     K.hom([top gen, next one down, etc.])
     5    make sure you include easy way to gens all the way down.
    86
    97[ ] Hess's algorithm
    108[ ] reduction algorithm
     
    2523
    2624
    2725DONE:
     26[x] inverses of fractional ideals
     27[x] factor for elements of the rational function field
     28[x] ideals
    2829[x] polynomial factoring of any univariate poly over a rational function field: reduce to bivariate over constant field?
    2930[x] conversion back and forth between a free module over base
    3031[x] random element