# HG changeset patch
# User sdietzel@cs.washington.edu
# Date 1264532149 28800
# Node ID a4965379b84fa1ba9539f018c3da09cd29f15619
# Parent 6c6a92e8529335ffd28f3b40f1f691055f5e3c08
trac 4492  block_matrix reacts inconsistently with 0.
diff r 6c6a92e85293 r a4965379b84f sage/matrix/constructor.py
a

b


990  990  
991  991  One can use constant entries:: 
992  992  
993   sage: block_matrix([1, A, 0, 1]) 
994   [ 1 0 3 9] 
995   [ 0 1 6 10] 
996   [+] 
997   [ 0 0 1 0] 
998   [ 0 0 0 1] 
 993  sage: block_matrix([1, A, 0, 2/3]) 
 994  [ 1 0 3 9] 
 995  [ 0 1 6 10] 
 996  [+] 
 997  [ 0 02/3 0] 
 998  [ 0 0 0 2/3] 
 999  
 1000  A zero entry may represent a square or nonsquare zero matrix. 
 1001  Note that in the first ambiguous example below this function turns 
 1002  0 into a square matrix. However, in the second example, the 
 1003  dimensions of the 0 matrices are not ambiguous:: 
 1004  
 1005  sage: A = matrix(QQ, 2, 2, [3,9,6,10]) 
 1006  sage: block_matrix([0, A, 0, A]) 
 1007  [ 0 0 3 9] 
 1008  [ 0 0 6 10] 
 1009  [+] 
 1010  [ 0 0 3 9] 
 1011  [ 0 0 6 10] 
 1012  sage: B = matrix(QQ, 1, 1, [ 1 ] ) 
 1013  sage: block_matrix([B, 0, 0, A]) 
 1014  [ 1 0 0] 
 1015  [+] 
 1016  [ 0 3 9] 
 1017  [ 0 6 10] 
999  1018  
1000  1019  One can specify the number of rows or columns (optional for square 
1001  1020  number of matrices):: 
… 
… 

1069  1088  for i in range(nrows): 
1070  1089  for j in range(0, ncols): 
1071  1090  x = sub_matrices[i*ncols+j] 
1072   if not is_Matrix(x) and x: # must be square matrix 
 1091  if not is_Matrix(x): # we make a square matrix in ambiguous cases, as documented above 
1073  1092  if row_heights[i] is None: 
1074  1093  row_heights[i] = col_widths[j] 
1075  1094  if col_widths[j] is None: 