# 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 zerosized matrices
diff git a/sage/matrix/matrix_integer_dense_saturation.py b/sage/matrix/matrix_integer_dense_saturation.py
a

b


266  266  return C.change_ring(ZZ)._insert_zero_columns(zero_cols) 
267  267  
268  268  def index_in_saturation(A, proof=True): 
269   """ 
 269  r""" 
270  270  The index of A in its saturation. 
271  271  
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``) 
275  277  
276  278  OUTPUT: 
277   an integer 
278  279  
279   EXAMPLES: 
 280  An integer 
 281  
 282  EXAMPLES:: 
 283  
280  284  sage: from sage.matrix.matrix_integer_dense_saturation import index_in_saturation 
281  285  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 
282  286  [11 16 21] 
… 
… 

287  291  sage: S = W.saturation() 
288  292  sage: W.index_in(S) 
289  293  18 
 294  
 295  TESTS:: 
 296  
 297  sage: zero = matrix(ZZ, [[]]) 
 298  sage: zero.index_in_saturation() 
 299  1 
290  300  """ 
291  301  r = A.rank() 
 302  if r==0 and (A.nrows()==0 or A.ncols()==0): 
 303  return 1 
292  304  if r < A.nrows(): 
293  305  A = A.hermite_form(proof=proof, include_zero_rows=False) 
294  306  if A.is_square(): 