Ticket #12361: trac_12361_index_in_saturation_fix.patch

File trac_12361_index_in_saturation_fix.patch, 1.5 KB (added by vbraun, 11 years ago)

Initial patch

  • sage/matrix/matrix_integer_dense_saturation.py

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1327550349 28800
    # Node ID 3e6b2ece46d859480525acb64790a25c3bd4da4a
    # Parent  32369a57f69dbd70cace5368c949e9420ee97f94
    Trac #12361: Fix index_in_saturation for zero-sized matrices
    
    diff --git a/sage/matrix/matrix_integer_dense_saturation.py b/sage/matrix/matrix_integer_dense_saturation.py
    a b  
    266266    return C.change_ring(ZZ)._insert_zero_columns(zero_cols)
    267267
    268268def index_in_saturation(A, proof=True):
    269     """
     269    r"""
    270270    The index of A in its saturation.
    271271
    272     INPUT:
    273         A -- matrix over ZZ
    274         proof -- bool (True or False)
     272    INPUT::
     273
     274    - ``A`` -- matrix over `\ZZ`
     275   
     276    - ``proof`` -- boolean (``True`` or ``False``)
    275277
    276278    OUTPUT:
    277         an integer
    278279
    279     EXAMPLES:
     280    An integer
     281
     282    EXAMPLES::
     283
    280284        sage: from sage.matrix.matrix_integer_dense_saturation import index_in_saturation
    281285        sage: A = matrix(ZZ, 2, 2, [3,2,3,4]); B = matrix(ZZ, 2,3,[1,2,3,4,5,6]); C = A*B; C
    282286        [11 16 21]
     
    287291        sage: S = W.saturation()
    288292        sage: W.index_in(S)
    289293        18
     294
     295    TESTS::
     296
     297        sage: zero = matrix(ZZ, [[]])
     298        sage: zero.index_in_saturation()
     299        1
    290300    """
    291301    r = A.rank()
     302    if r==0 and (A.nrows()==0 or A.ncols()==0):
     303        return 1
    292304    if r < A.nrows():
    293305        A = A.hermite_form(proof=proof, include_zero_rows=False)
    294306    if A.is_square():