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.576980839012 - 1.17091282993*I 0.232362216253 - 0.318581071175*I 0.880672963687 -<br />

[ -0.537261143636 - 0.686091014267*I 0.591339766401 + 0.158450627525*I -0.561877938537 +<br />

sage: ( m - L*L.conjugate().transpose() ).norm(1) < 1e-20<br />

True<br />

sage: L.parent()<br />

Full MatrixSpace <strong>of</strong> 6 by 6 dense matrices over Complex Field with 100 bits <strong>of</strong> precision<br />

sage: L[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 />

Here is an example that returns an incorrect answer, because the input is not positive definite:<br />

sage: r = matrix(CDF, 2, 2, [ 1, -2*I, 2*I, 0 ]); r<br />

[ 1.0 -2.0*I]<br />

[ 2.0*I 0.0]<br />

sage: r.eigenvalues()<br />

[2.56155281281, -1.56155281281]<br />

sage: ( r - r.conjugate().transpose() ).norm(1) < 1e-30<br />

True<br />

sage: L = r.cholesky_decomposition(); L<br />

[ 1.0 0.0]<br />

[2.0*I 2.0*I]<br />

sage: L*L.conjugate().transpose()<br />

[ 1.0 -2.0*I]<br />

[ 2.0*I 8.0]<br />

This test verifies that the caching <strong>of</strong> the two variants <strong>of</strong> the Cholesky decomposition have been cleanly<br />

separated. It can be safely removed as part <strong>of</strong> removing this method at the end <strong>of</strong> the deprecation period.<br />

(From trac ticket #13045.)<br />

sage: r = matrix(CDF, 2, 2, [ 0, -2*I, 2*I, 0 ]); r<br />

[ 0.0 -2.0*I]<br />

[ 2.0*I 0.0]<br />

sage: r.cholesky_decomposition()<br />

[ 0.0 0.0]<br />

[NaN + NaN*I NaN + NaN*I]<br />

sage: r.cholesky()<br />

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

...<br />

ValueError: matrix is not positive definite<br />

sage: r[0,0] = 0 # clears cache<br />

sage: r.cholesky()<br />

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

...<br />

ValueError: matrix is not positive definite<br />

sage: r.cholesky_decomposition()<br />

[ 0.0 0.0]<br />

[NaN + NaN*I NaN + NaN*I]<br />

column_module()<br />

Return the free module over the base ring spanned by the columns <strong>of</strong> this matrix.<br />

EXAMPLES:<br />

sage: t = matrix(QQ, 3, range(9)); t<br />

[0 1 2]<br />

[3 4 5]<br />

[6 7 8]<br />

141

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

Saved successfully!

Ooh no, something went wrong!