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

This is not the case for matrices over the integers, rationals or algebraic numbers, since the computations<br />

are done in the algebraically closed field <strong>of</strong> algebraic numbers.<br />

Here is an example where the similarity is obvious, but the routine fails to compute a result.<br />

sage: F. = FiniteField(7^2)<br />

sage: C = matrix(F,[[ a + 2, 5*a + 4],<br />

... [6*a + 6, 6*a + 4]])<br />

sage: S = matrix(ZZ, [[0, 1],<br />

... [1, 0]])<br />

sage: D = S.inverse()*C*S<br />

sage: C.is_similar(D)<br />

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

...<br />

ValueError: unable to compute Jordan canonical form for a matrix<br />

sage: C.jordan_form()<br />

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

...<br />

RuntimeError: Some eigenvalue does not exist in Finite Field in a <strong>of</strong> size 7^2.<br />

Inexact rings <strong>and</strong> fields are also not supported.<br />

sage: A = matrix(CDF, 2, 2, range(4))<br />

sage: B = copy(A)<br />

sage: A.is_similar(B)<br />

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

...<br />

ValueError: unable to compute Jordan canonical form for a matrix<br />

Rectangular matrices <strong>and</strong> mismatched sizes return quickly.<br />

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

sage: B = copy(A)<br />

sage: A.is_similar(B)<br />

False<br />

sage: A = matrix(2, 2, range(4))<br />

sage: B = matrix(3, 3, range(9))<br />

sage: A.is_similar(B, transformation=True)<br />

(False, None)<br />

If the fraction fields <strong>of</strong> the entries are unequal, it is an error, except in the case when the rationals gets<br />

promoted to the algebraic numbers.<br />

sage: A = matrix(ZZ, 2, 2, range(4))<br />

sage: B = matrix(GF(2), 2, 2, range(4))<br />

sage: A.is_similar(B, transformation=True)<br />

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

...<br />

TypeError: matrices need to have entries with identical fraction fields, not Algebraic Field<br />

sage: A = matrix(ZZ, 2, 2, range(4))<br />

sage: B = matrix(QQbar, 2, 2, range(4))<br />

sage: A.is_similar(B)<br />

True<br />

Inputs are checked.<br />

sage: A = matrix(ZZ, 2, 2, range(4))<br />

sage: A.is_similar(’garbage’)<br />

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

...<br />

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