# HG changeset patch
# Parent e6342acc32daf541a4670ee1f4539c3e2a28a21a
# User Keshav Kini <kini@member.ams.org>
# Date 1300759270 25200
10974: minor formatting for matrix augment and stack
diff git a/sage/matrix/matrix1.pyx b/sage/matrix/matrix1.pyx
a

b


981  981  return V(tmp, coerce=False, copy=False, check=False) 
982  982  
983  983  
984   ############################################################################################ 
 984  ########################################################################### 
985  985  # Building matrices out of other matrices, rows, or columns 
986   ############################################################################################ 
 986  ########################################################################### 
987  987  def stack(self, bottom, subdivide=False): 
988  988  r""" 
989  989  Returns a new matrix formed by appending the matrix 
… 
… 

1185  1185  if hasattr(bottom, '_vector_'): 
1186  1186  bottom = bottom.row() 
1187  1187  if not isinstance(bottom, sage.matrix.matrix1.Matrix): 
1188   raise TypeError('a matrix must be stacked with another matrix, or a vector') 
 1188  raise TypeError('a matrix must be stacked with another matrix, or ' 
 1189  'a vector') 
1189  1190  
1190  1191  cdef Matrix other 
1191  1192  other = bottom 
1192  1193  
1193  1194  if self._ncols != other._ncols: 
1194   raise TypeError('number of columns must be the same, {0} != {1}'.format(self._ncols, other._ncols)) 
 1195  raise TypeError('number of columns must be the same, ' 
 1196  '{0} != {1}'.format(self._ncols, other._ncols)) 
1195  1197  if not (self._base_ring is other.base_ring()): 
1196  1198  other = other.change_ring(self._base_ring) 
1197  1199  
… 
… 

1215  1217  
1216  1218  def augment(self, right, subdivide=False): 
1217  1219  r""" 
1218   Returns a new matrix formed by appending the matrix 
1219   (or vector) ``right`` on the right side of ``self``. 
 1220  Returns a new matrix formed by appending the matrix (or vector) 
 1221  ``right`` on the right side of ``self``. 
1220  1222  
1221  1223  INPUT: 
1222  1224  
… 
… 

1224  1226  dimensions are compatible with ``self``. 
1225  1227  
1226  1228   ``subdivide``  default: ``False``  request the resulting 
1227   matrix to have a new subdivision, separating ``self`` from ``right``. 
 1229  matrix to have a new subdivision, separating ``self`` from 
 1230  ``right``. 
1228  1231  
1229  1232  OUTPUT: 
1230  1233  
1231   A new matrix formed by appending ``right`` onto the right side of ``self``. 
1232   If ``right`` is a vector (or free module element) then in this context 
1233   it is appropriate to consider it as a column vector. (The code first 
1234   converts a vector to a 1column matrix.) 
 1234  A new matrix formed by appending ``right`` onto the right side 
 1235  of ``self``. If ``right`` is a vector (or free module element) 
 1236  then in this context it is appropriate to consider it as a 
 1237  column vector. (The code first converts a vector to a 1column 
 1238  matrix.) 
1235  1239  
1236  1240  If ``subdivide`` is ``True`` then any column subdivisions for 
1237  1241  the two matrices are preserved, and a new subdivision is added 
1238  1242  between ``self`` and ``right``. If the row divisions are 
1239   identical, then they are preserved, otherwise they are discarded. 
1240   When ``subdivide`` is ``False`` there is no subdivision information 
1241   in the result. 
 1243  identical, then they are preserved, otherwise they are 
 1244  discarded. When ``subdivide`` is ``False`` there is no 
 1245  subdivision information in the result. 
1242  1246  
1243  1247  .. warning:: 
1244  1248  If ``subdivide`` is ``True`` then unequal row subdivisions 
1245   will be discarded, since it would be ambiguous how to interpret 
1246   them. If the subdivision behavior is not what you need, 
1247   you can manage subdivisions yourself with methods like 
1248   :meth:`~sage.matrix.matrix2.Matrix.get_subdivisions` 
1249   and 
1250   :meth:`~sage.matrix.matrix2.Matrix.subdivide`. 
1251   You might also find :func:`~sage.matrix.constructor.block_matrix` 
1252   or 
 1249  will be discarded, since it would be ambiguous how to 
 1250  interpret them. If the subdivision behavior is not what you 
 1251  need, you can manage subdivisions yourself with methods like 
 1252  :meth:`~sage.matrix.matrix2.Matrix.get_subdivisions` and 
 1253  :meth:`~sage.matrix.matrix2.Matrix.subdivide`. You might 
 1254  also find :func:`~sage.matrix.constructor.block_matrix` or 
1253  1255  :func:`~sage.matrix.constructor.block_diagonal_matrix` 
1254  1256  useful and simpler in some instances. 
1255  1257  
… 
… 

1311  1313  [233 45] 
1312  1314  [456 78] 
1313  1315  
1314   Row subdivisions can be preserved, but only if they are identical. 
1315   Otherwise, this information is discarded and must be managed 
1316   separately. :: 
 1316  Row subdivisions can be preserved, but only if they are 
 1317  identical. Otherwise, this information is discarded and must be 
 1318  managed separately. :: 
1317  1319  
1318  1320  sage: A = matrix(QQ, 3, range(6)) 
1319  1321  sage: A.subdivide([1,3], None) 
… 
… 

1332  1334  [2 33 4 5] 
1333  1335  [4 56 7 8] 
1334  1336  
1335   The result retains the base ring of ``self`` by coercing 
1336   the elements of ``right`` into the base ring of ``self``. :: 
 1337  The result retains the base ring of ``self`` by coercing the 
 1338  elements of ``right`` into the base ring of ``self``. :: 
1337  1339  
1338  1340  sage: A = matrix(QQ, 2, [1,2]) 
1339  1341  sage: B = matrix(RR, 2, [sin(1.1), sin(2.2)]) 
… 
… 

1349  1351  sage: D.parent() 
1350  1352  Full MatrixSpace of 2 by 2 dense matrices over Real Field with 53 bits of precision 
1351  1353  
1352   Sometimes it is not possible to coerce into the base ring 
1353   of ``self``. A solution is to change the base ring of ``self`` 
1354   to a more expansive ring. Here we mix the rationals with 
1355   a ring of polynomials with rational coefficients. :: 
 1354  Sometimes it is not possible to coerce into the base ring of 
 1355  ``self``. A solution is to change the base ring of ``self`` to 
 1356  a more expansive ring. Here we mix the rationals with a ring of 
 1357  polynomials with rational coefficients. :: 
1356  1358  
1357  1359  sage: R = PolynomialRing(QQ, 'y') 
1358  1360  sage: A = matrix(QQ, 1, [1,2]) 
… 
… 

1384  1386  if hasattr(right, '_vector_'): 
1385  1387  right = right.column() 
1386  1388  if not isinstance(right, sage.matrix.matrix1.Matrix): 
1387   raise TypeError("a matrix must be augmented with another matrix, or a vector") 
 1389  raise TypeError("a matrix must be augmented with another matrix, " 
 1390  "or a vector") 
1388  1391  
1389  1392  cdef Matrix other 
1390  1393  other = right 
1391  1394  
1392  1395  if self._nrows != other._nrows: 
1393   raise TypeError('number of rows must be the same, {0} != {1}'.format(self._nrows, other._nrows)) 
 1396  raise TypeError('number of rows must be the same, ' 
 1397  '{0} != {1}'.format(self._nrows, other._nrows)) 
1394  1398  if not (self._base_ring is other.base_ring()): 
1395  1399  other = other.change_ring(self._base_ring) 
1396  1400  