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

[0.0 1.0 0.0]<br />

[0.0 0.0 1.0]<br />

TESTS:<br />

sage: m = matrix(RDF,3,2,range(1, 7)); m<br />

[1.0 2.0]<br />

[3.0 4.0]<br />

[5.0 6.0]<br />

sage: U,S,V = m.SVD()<br />

sage: U*S*V.transpose()<br />

[1.0 2.0]<br />

[3.0 4.0]<br />

[5.0 6.0]<br />

sage: m = matrix(RDF, 3, 0, []); m<br />

[]<br />

sage: m.SVD()<br />

([], [], [])<br />

sage: m = matrix(RDF, 0, 3, []); m<br />

[]<br />

sage: m.SVD()<br />

([], [], [])<br />

sage: def shape(x): return (x.nrows(), x.ncols())<br />

sage: m = matrix(RDF, 2, 3, range(6))<br />

sage: map(shape, m.SVD())<br />

[(2, 2), (2, 3), (3, 3)]<br />

sage: for x in m.SVD(): x.is_immutable()<br />

True<br />

True<br />

True<br />

cholesky()<br />

Returns the Cholesky factorization <strong>of</strong> a matrix that is real symmetric, or complex Hermitian.<br />

INPUT:<br />

Any square matrix with entries from RDF that is symmetric, or with entries from CDF that is Hermitian.<br />

The matrix must be positive definite for the Cholesky decomposition to exist.<br />

OUTPUT:<br />

For a matrix A the routine returns a lower triangular matrix L such that,<br />

A = LL ∗<br />

where L ∗ is the conjugate-transpose in the complex case, <strong>and</strong> just the transpose in the real case. If the<br />

matrix fails to be positive definite (perhaps because it is not symmetric or Hermitian), then this function<br />

raises a ValueError.<br />

IMPLEMENTATION:<br />

The existence <strong>of</strong> a Cholesky decomposition <strong>and</strong> the positive definite property are equivalent. So this<br />

method <strong>and</strong> the is_positive_definite() method compute <strong>and</strong> cache both the Cholesky decomposition<br />

<strong>and</strong> the positive-definiteness. So the is_positive_definite() method or catching a<br />

ValueError from the cholesky() method are equally expensive computationally <strong>and</strong> if the decomposition<br />

exists, it is cached as a side-effect <strong>of</strong> either routine.<br />

EXAMPLES:<br />

A real matrix that is symmetric <strong>and</strong> positive definite.<br />

356 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!