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] |
i2 : m = genericMatrix(R, a, 3, 5) |
i3 : submatrix(m, {1,2,0}, {0..2, 4}) |
If rows or cols is omitted, all the indices are used.
i4 : submatrix(m, {1,2}, ) |
It is an error if any element of rows or cols is out of range.
Ways to use submatrix :