next | previous | forward | backward | up | top | index | toc | Macaulay2 website
Macaulay2Doc :: submatrix(Matrix,VisibleList,VisibleList)

submatrix(Matrix,VisibleList,VisibleList) -- select part of a matrix

Synopsis

Description

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 f_(rows_i, cols_j).

Each list of integers may contain ranges and repetitions, as in {3, 5..7, 3:0}

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

Both rows and/or cols may contain duplicate values, in which case the result will contain duplicate rows and/or columns.

i1 : R = ZZ/101[a .. o];
i2 : f = 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(f, {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

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

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

             2       5
o4 : Matrix R  <--- R
submatrix(f,,cols) can be written as submatrix(f,cols), or f_cols.
i5 : submatrix(f,,{0,1})

o5 = | a d |
     | b e |
     | c f |

             3       2
o5 : Matrix R  <--- R
i6 : f_{0,1}

o6 = | a d |
     | b e |
     | c f |

             3       2
o6 : Matrix R  <--- R

See also