submatrix

submatrix(m, rows, cols) -- yields a submatrix of the matrix m.
submatrix(m, cols) -- yields a submatrix of the matrix m.

Yields an r by c matrix, where r is the length of the list of integers rows, and c is the length of the list of integers cols. The (i,j)-th entry of the result is m_(rows_i, cols_j). If necessary, any sequences in the lists are spliced into the list.

i1 : R = ZZ/101[a .. o]

o1 = R

o1 : PolynomialRing
i2 : m = genericMatrix(R, a, 3, 5)

o2 = {0} | a d g j m |
     {0} | b e h k n |
     {0} | c f i l o |

             3       5
o2 : Matrix R  <--- R
i3 : submatrix(m, {1,2,0}, {0..2, 4})

o3 = {0} | b e h n |
     {0} | c f i o |
     {0} | a d g m |

             3       4
o3 : Matrix R  <--- R

If rows or cols is omitted, all the indices are used.

i4 : submatrix(m, {1,2}, )

o4 = {0} | b e h k n |
     {0} | c f i l o |

             2       5
o4 : Matrix R  <--- R

It is an error if any element of rows or cols is out of range.


topindexpreviousupnext