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

2<br />

sage: A = Arat.change_ring(CDF)<br />

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

sage: R._normalize_rows().round(6).zero_at(10^-6)<br />

[ 5.567764 -2.69408 2.69408]<br />

[ 0.0 3.569585 -3.569585]<br />

[ 0.0 0.0 0.0]<br />

[ 0.0 0.0 0.0]<br />

sage: (Q.conjugate_transpose()*Q).zero_at(10^-14)<br />

[1.0 0.0 0.0 0.0]<br />

[0.0 1.0 0.0 0.0]<br />

[0.0 0.0 1.0 0.0]<br />

[0.0 0.0 0.0 1.0]<br />

Results are cached, meaning they are immutable matrices. Make a copy if you need to manipulate a result.<br />

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

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

sage: Q.is_mutable()<br />

False<br />

sage: R.is_mutable()<br />

False<br />

sage: Q[0,0] = 0<br />

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

...<br />

ValueError: matrix is immutable; please change a copy instead (i.e., use copy(M) to change a<br />

sage: Qcopy = copy(Q)<br />

sage: Qcopy[0,0] = 679<br />

sage: Qcopy[0,0]<br />

679.0<br />

TESTS:<br />

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

trac ticket #10795.<br />

sage: A = zero_matrix(RDF, 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(RDF, 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.0 0.0]<br />

[0.0 1.0 0.0]<br />

[0.0 0.0 1.0]<br />

SVD(*args, **kwds)<br />

Return the singular value decomposition <strong>of</strong> this matrix.<br />

The U <strong>and</strong> V matrices are not unique <strong>and</strong> may be returned with different values in the future or on different<br />

systems. The S matrix is unique <strong>and</strong> contains the singular values in descending order.<br />

The computed decomposition is cached <strong>and</strong> returned on subsequent calls.<br />

354 Chapter 19. Dense matrices using a NumPy backend.

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

Saved successfully!

Ooh no, something went wrong!