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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<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: B=r<strong>and</strong>om_matrix(QQ,3,num_bound=10); B<br />

[ -4 -3 6]<br />

[ 5 -5 9/2]<br />

[3/2 -4 -7]<br />

sage: B.rref()<br />

[1 0 0]<br />

[0 1 0]<br />

[0 0 1]<br />

In this case, since B is a matrix over a field (the rational numbers), rref() <strong>and</strong> echelon_form() are<br />

exactly the same:<br />

sage: B.echelon_form()<br />

[1 0 0]<br />

[0 1 0]<br />

[0 0 1]<br />

sage: B.echelon_form() is B.rref()<br />

True<br />

Since echelon_form() is not implemented for every ring, sometimes behavior varies, as here:<br />

sage: R.=ZZ[]<br />

sage: C = matrix(3,[2,x,x^2,x+1,3-x,-1,3,2,1])<br />

sage: C.rref()<br />

[1 0 0]<br />

[0 1 0]<br />

[0 0 1]<br />

sage: C.base_ring()<br />

Univariate Polynomial Ring in x over Integer Ring<br />

sage: C.echelon_form()<br />

Traceback (most recent call last):<br />

...<br />

NotImplementedError: Ideal Ideal (2, x + 1) <strong>of</strong> Univariate Polynomial Ring in x over Integer<br />

Echelon form not implemented over ’Univariate Polynomial Ring in x over Integer Ring’.<br />

sage: C = matrix(3,[2,x,x^2,x+1,3-x,-1,3,2,1/2])<br />

sage: C.echelon_form()<br />

[ 2 x<br />

[ 0 1 15*x^2 - 3/2*x<br />

[ 0 0 5/2*x^3 - 15/4*x^2 - 9/4*<br />

sage: C.rref()<br />

[1 0 0]<br />

[0 1 0]<br />

[0 0 1]<br />

sage: C = matrix(3,[2,x,x^2,x+1,3-x,-1/x,3,2,1/2])<br />

sage: C.echelon_form()<br />

[1 0 0]<br />

[0 1 0]<br />

[0 0 1]<br />

set_block(row, col, block)<br />

Sets the sub-matrix <strong>of</strong> self, with upper left corner given by row, col to block.<br />

EXAMPLES:<br />

sage: A = matrix(QQ, 3, 3, range(9))/2<br />

sage: B = matrix(ZZ, 2, 1, [100,200])<br />

sage: A.set_block(0, 1, B)<br />

sage: A<br />

[ 0 100 1]<br />

251

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

Saved successfully!

Ooh no, something went wrong!