Ticket #13034: trac_13034_fix_index_in_saturation.patch

File trac_13034_fix_index_in_saturation.patch, 1.2 KB (added by novoselt, 10 years ago)
  • sage/matrix/matrix_integer_dense_saturation.py

    # HG changeset patch
    # User Andrey Novoseltsev <novoselt@gmail.com>
    # Date 1338140774 25200
    # Node ID 1bbc031d6498bff306d1471339535a830a7c7d69
    # Parent  ae50c303447a1bd26a709ac91c5254ee30e4baa2
    Make index_in_saturation of zero matrices return 1 instead of exception.
    
    diff --git a/sage/matrix/matrix_integer_dense_saturation.py b/sage/matrix/matrix_integer_dense_saturation.py
    a b  
    291291        sage: S = W.saturation()
    292292        sage: W.index_in(S)
    293293        18
     294       
     295    For any zero matrix the index in its saturation is 1 (see :trac:`13034`)::
     296   
     297        sage: m = matrix(ZZ, 3)
     298        sage: m
     299        [0 0 0]
     300        [0 0 0]
     301        [0 0 0]
     302        sage: m.index_in_saturation()
     303        1
     304        sage: m = matrix(ZZ, 2, 3)
     305        sage: m
     306        [0 0 0]
     307        [0 0 0]
     308        sage: m.index_in_saturation()
     309        1
    294310
    295311    TESTS::
    296312
     
    299315        1
    300316    """
    301317    r = A.rank()
    302     if r==0 and (A.nrows()==0 or A.ncols()==0):
    303         return 1
     318    if r == 0:
     319        return ZZ(1)
    304320    if r < A.nrows():
    305321        A = A.hermite_form(proof=proof, include_zero_rows=False)
    306322    if A.is_square():