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 />

[ 0.3592106040535498 -0.5693261797050169]<br />

[-0.1796053020267749 0.1445907757980996]<br />

[-0.1796053020267749 0.7048800320157352]<br />

[-0.8980265101338745 -0.3976246334447737]<br />

sage: R<br />

[ 5.567764362830022 -2.694079530401624 2.694079530401624]<br />

[ 0 3.569584777515583 -3.569584777515583]<br />

sage: Q.conjugate_transpose()*Q<br />

[ 1 0.e-18]<br />

[0.e-18 1]<br />

Another rank-deficient rectangular matrix, with complex entries, as a reduced decomposition.<br />

sage: A = matrix(QQbar, [[-3*I - 3, I - 3, -12*I + 1, -2],<br />

... [-I - 1, -2, 5*I - 1, -I - 2],<br />

... [-4*I - 4, I - 5, -7*I, -I - 4]])<br />

sage: Q, R = A.QR(full=False)<br />

sage: Q<br />

[ -0.4160251471689219 - 0.4160251471689219*I 0.5370861555295747 + 0.1790287185098583*I<br />

[ -0.1386750490563073 - 0.1386750490563073*I<br />

[ -0.5547001962252291 - 0.5547001962252291*I<br />

-0.7519206177414046 - 0.2506402059138015*I<br />

-0.2148344622118299 - 0.07161148740394329*I<br />

sage: R<br />

[ 7.211102550927979 3.328201177351375 - 5.269651864139676*I 7.9<br />

[ 0 1.074172311059150 -1.6<br />

sage: Q.conjugate_transpose()*Q<br />

[1.000000000000000 + 0.e-18*I 0.e-18 + 0.e-18*I]<br />

[ 0.e-17 + 0.e-17*I 1.000000000000000 + 0.e-17*I]<br />

sage: Q*R-A<br />

[0.e-18 + 0.e-18*I 0.e-18 + 0.e-18*I 0.e-17 + 0.e-17*I 0.e-18 + 0.e-18*I]<br />

[0.e-18 + 0.e-18*I 0.e-18 + 0.e-18*I 0.e-18 + 0.e-17*I 0.e-18 + 0.e-18*I]<br />

[0.e-18 + 0.e-18*I 0.e-17 + 0.e-18*I 0.e-17 + 0.e-17*I 0.e-18 + 0.e-18*I]<br />

Results <strong>of</strong> full decompositions are cached <strong>and</strong> thus returned immutable.<br />

sage: A = r<strong>and</strong>om_matrix(QQbar, 2, 2)<br />

sage: Q, R = A.QR()<br />

sage: Q.is_mutable()<br />

False<br />

sage: R.is_mutable()<br />

False<br />

Trivial cases return trivial results <strong>of</strong> the correct size, <strong>and</strong> we check Q itself in one case.<br />

sage: A = zero_matrix(QQbar, 0, 10)<br />

sage: Q, R = A.QR()<br />

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

(0, 0)<br />

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

(0, 10)<br />

sage: A = zero_matrix(QQbar, 3, 0)<br />

sage: Q, R = A.QR()<br />

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

(3, 3)<br />

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

(3, 0)<br />

sage: Q<br />

[1 0 0]<br />

[0 1 0]<br />

[0 0 1]<br />

129

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

Saved successfully!

Ooh no, something went wrong!