[top][index]
search for:

submatrix -- select part of a matrix

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 = | a d g j m |
     | b e h k n |
     | c f i l o |

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

o3 = | b e h n |
     | c f i o |
     | 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 = | b e h k n |
     | 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.

Ways to use submatrix :

  • submatrix(Matrix,Sequence,Sequence)
  • submatrix(Matrix,Sequence,List)
  • submatrix(Matrix,List)
  • submatrix(Matrix,List,Sequence)
  • submatrix(Matrix,List,List)
  • submatrix(Matrix,List,Nothing)
  • submatrix(Matrix,Nothing,List)

  • [top][index]
    search for: