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 1 0 0 0]<br />

[ 3 -2 1 0 0]<br />

[ 2 -1 0 1 0]<br />

[-3 1 -3 1 1]<br />

sage: D<br />

[ 3 0 0 0 0]<br />

[ 0 -1 0 0 0]<br />

[ 0 0 5 0 0]<br />

[ 0 0 0 -2 0]<br />

[ 0 0 0 0 -1]<br />

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

True<br />

Optionally, Hermitian matrices can be factored <strong>and</strong> the result has a similar property (but not identical).<br />

Here, the field is all complex numbers with rational real <strong>and</strong> imaginary parts. As theory predicts, the<br />

diagonal entries will be real numbers.<br />

sage: C. = QuadraticField(-1)<br />

sage: B = matrix(C, [[ 2, 4 - 2*I, 2 + 2*I],<br />

... [4 + 2*I, 8, 10*I],<br />

... [2 - 2*I, -10*I, -3]])<br />

sage: B.is_hermitian()<br />

True<br />

sage: L, d = B.indefinite_factorization(algorithm=’hermitian’)<br />

sage: D = diagonal_matrix(d)<br />

sage: L<br />

[ 1 0 0]<br />

[ I + 2 1 0]<br />

[ -I + 1 2*I + 1 1]<br />

sage: D<br />

[ 2 0 0]<br />

[ 0 -2 0]<br />

[ 0 0 3]<br />

sage: B == L*D*L.conjugate_transpose()<br />

True<br />

If a leading principal submatrix has zero determinant, this algorithm will fail. This will never happen with<br />

a positive definite matrix.<br />

sage: A = matrix(QQ, [[21, 15, 12, -2],<br />

... [15, 12, 9, 6],<br />

... [12, 9, 7, 3],<br />

... [-2, 6, 3, 8]])<br />

sage: A.is_symmetric()<br />

True<br />

sage: A[0:3,0:3].det() == 0<br />

True<br />

sage: A.indefinite_factorization()<br />

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

...<br />

ValueError: 3x3 leading principal submatrix is singular,<br />

so cannot create indefinite factorization<br />

This algorithm only depends on field operations, so outside <strong>of</strong> the singular submatrix situation, any matrix<br />

may be factored. This provides a reasonable alternative to the Cholesky decomposition.<br />

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

sage: A = matrix(F,<br />

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

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