On 4/23/07, didier deshommes <[EMAIL PROTECTED]> wrote:
>
> Hi there,
> How do I make submatrices (or minors, or block submatrices) in SAGE? I
> have a 5x5 matrix
> {{{
> [ 0 1 0 0 0]
> [ 0 0 0 0 1]
> [ 0 0 0 1 0]
> [ 5/3 -2 -1 2/3 5/3]
> [-17/3 1 4 4/3 1/3]
> }}}
>
> and I would like to extract from it the first block 2x2 submatrix, ie
> [0 1]
> [0 0]
>
> Any ideas on how to do this?
>From the reference manual:
matrix_from_rows_and_columns( )
Return the matrix constructed from self from the given rows and columns.
sage: M = MatrixSpace(Integers(8),3,3)
sage: A = M(range(9)); A
[0 1 2]
[3 4 5]
[6 7 0]
sage: A.matrix_from_rows_and_columns([1], [0,2])
[3 5]
sage: A.matrix_from_rows_and_columns([1,2], [1,2])
[4 5]
[7 0]
Note that row and column indices can be reordered or repeated:
sage: A.matrix_from_rows_and_columns([2,1], [2,1])
[0 7]
[5 4]
For example here we take from row 1 columns 2 then 0 twice, and do
this 3 times.
sage: A.matrix_from_rows_and_columns([1,1,1],[2,0,0])
[5 3 3]
[5 3 3]
[5 3 3]
>
> didier
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---