08.02.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Matrices</strong> <strong>and</strong> <strong>Spaces</strong> <strong>of</strong> <strong>Matrices</strong>, Release 6.1.1<br />

sage: from sage.matrix.constructor import r<strong>and</strong>om_subspaces_matrix<br />

sage: matrix_space = sage.matrix.matrix_space.MatrixSpace(QQ, 6, 8)<br />

sage: B=r<strong>and</strong>om_subspaces_matrix(matrix_space, rank=3); B # r<strong>and</strong>om<br />

[ 113 339 -46 218 -243 641 -269 -306]<br />

[ -33 -99 13 -63 69 -185 77 90]<br />

[ 35 105 -14 67 -74 197 -82 -95]<br />

[ -18 -54 7 -34 37 -100 41 49]<br />

[ -26 -78 10 -49 53 -144 59 71]<br />

[ -8 -24 3 -15 16 -44 18 22]<br />

sage: B.rank()<br />

3<br />

sage: B.nullity()<br />

3<br />

sage: (B.nrows(), B.ncols())<br />

(6, 8)<br />

sage: all([x in ZZ for x in B.list()])<br />

True<br />

sage: B_exp<strong>and</strong>ed=B.augment(identity_matrix(6)).rref()<br />

sage: all([x in ZZ for x in B_exp<strong>and</strong>ed.list()])<br />

True<br />

sage: B_exp<strong>and</strong>ed # r<strong>and</strong>om<br />

[ 1 3 0 0 1 1 3 -2 0 0 -3 0 -9 16]<br />

[ 0 0 1 0 3 -2 -1 -3 0 0 2 0 11 -27]<br />

[ 0 0 0 1 -1 2 -3 -1 0 0 2 0 7 -14]<br />

[ 0 0 0 0 0 0 0 0 1 0 -5 0 -3 2]<br />

[ 0 0 0 0 0 0 0 0 0 1 1 0 1 -3]<br />

[ 0 0 0 0 0 0 0 0 0 0 0 1 -1 1]<br />

Check that we fixed Trac #10543 (echelon forms should be immutable):<br />

sage: B_exp<strong>and</strong>ed.is_immutable()<br />

True<br />

We want to modify B_exp<strong>and</strong>ed, so replace it with a copy:<br />

sage: B_exp<strong>and</strong>ed = copy(B_exp<strong>and</strong>ed)<br />

sage: B_exp<strong>and</strong>ed.subdivide(B.nrows()-B.nullity(),B.ncols());B_exp<strong>and</strong>ed # r<strong>and</strong>om<br />

[ 1 3 0 0 1 1 3 -2| 0 0 -3 0 -9 16]<br />

[ 0 0 1 0 3 -2 -1 -3| 0 0 2 0 11 -27]<br />

[ 0 0 0 1 -1 2 -3 -1| 0 0 2 0 7 -14]<br />

[-------------------------------+-----------------------]<br />

[ 0 0 0 0 0 0 0 0| 1 0 -5 0 -3 2]<br />

[ 0 0 0 0 0 0 0 0| 0 1 1 0 1 -3]<br />

[ 0 0 0 0 0 0 0 0| 0 0 0 1 -1 1]<br />

sage: C=B_exp<strong>and</strong>ed.subdivision(0,0)<br />

sage: C # r<strong>and</strong>om<br />

[ 1 3 0 0 1 1 3 -2]<br />

[ 0 0 1 0 3 -2 -1 -3]<br />

[ 0 0 0 1 -1 2 -3 -1]<br />

sage: L=B_exp<strong>and</strong>ed.subdivision(1,1)<br />

sage: L # r<strong>and</strong>om<br />

[ 1 0 -5 0 -3 2]<br />

[ 0 1 1 0 1 -3]<br />

[ 0 0 0 1 -1 1]<br />

sage: B.right_kernel()==C.right_kernel()<br />

True<br />

sage: B.row_space()==C.row_space()<br />

True<br />

sage: B.column_space()==L.right_kernel()<br />

54 Chapter 2. Matrix Constructor

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!