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

sage: [A[:i,:i].determinant() for i in range(1,A.nrows()+1)]<br />

[21, 27, 0, 0]<br />

sage: A.cholesky()<br />

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

...<br />

ValueError: matrix is not positive definite,<br />

so cannot compute Cholesky decomposition<br />

Even in light <strong>of</strong> the above, you can sometimes get lucky <strong>and</strong> arrive at a situation where a particular matrix<br />

has a Cholesky decomposition when the general characteristics <strong>of</strong> the matrix suggest this routine would<br />

fail. In this example, the indefinite factorization produces a diagonal matrix whose elements from the finite<br />

field convert naturally to positive integers <strong>and</strong> are also perfect squares.<br />

sage: F. = FiniteField(5^3)<br />

sage: A = matrix(F, [[ 4, 2*a^2 + 3, 4*a + 1],<br />

... [ 2*a^2 + 3, 2*a + 2, 4*a^2 + 4*a + 4],<br />

... [ 4*a + 1, 4*a^2 + 4*a + 4, a^2 + 4*a]])<br />

sage: A.is_symmetric()<br />

True<br />

sage: L = A.cholesky()<br />

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

True<br />

TESTS:<br />

This verifies that trac ticket #11274 is resolved.<br />

sage: E = matrix(QQ, [[2, 1], [1, 1]])<br />

sage: E.is_symmetric()<br />

True<br />

sage: E.eigenvalues()<br />

[0.38..., 2.61...]<br />

sage: E.det()<br />

1<br />

sage: E.cholesky()<br />

[ 1.414213562373095 0]<br />

[0.7071067811865475 0.7071067811865475]<br />

AUTHOR:<br />

•Rob Beezer (2012-05-27)<br />

cholesky_decomposition()<br />

Return the Cholesky decomposition <strong>of</strong> self.<br />

Warning: cholesky_decomposition() is deprecated, please use cholesky() instead.<br />

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

solve_left() may also take advantage <strong>of</strong> the cached decomposition depending on the exact implementation.<br />

INPUT:<br />

The input matrix must be:<br />

•real, symmetric, <strong>and</strong> positive definite; or<br />

•complex, Hermitian, <strong>and</strong> positive definite.<br />

If not, a ValueError exception will be raised.<br />

138 Chapter 7. Base class for matrices, part 2

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

Saved successfully!

Ooh no, something went wrong!