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

[-+---]<br />

[6|7 8]<br />

sage: a.change_ring(GF(3))<br />

[0|1 2]<br />

[0|1 2]<br />

[-+---]<br />

[0|1 2]<br />

charpoly(var=’x’, algorithm=’linbox’)<br />

Return the characteristic polynomial <strong>of</strong> this matrix.<br />

INPUT:<br />

•var - ‘x’ (string)<br />

•algorithm - ‘linbox’ (default) or ‘generic’<br />

OUTPUT: a polynomial over the rational numbers.<br />

EXAMPLES:<br />

sage: a = matrix(QQ, 3, [4/3, 2/5, 1/5, 4, -3/2, 0, 0, -2/3, 3/4])<br />

sage: f = a.charpoly(); f<br />

x^3 - 7/12*x^2 - 149/40*x + 97/30<br />

sage: f(a)<br />

[0 0 0]<br />

[0 0 0]<br />

[0 0 0]<br />

TESTS:<br />

The cached polynomial should be independent <strong>of</strong> the var argument (trac ticket #12292). We check (indirectly)<br />

that the second call uses the cached value by noting that its result is not cached:<br />

sage: M = MatrixSpace(QQ, 2)<br />

sage: A = M(range(0, 2^2))<br />

sage: type(A)<br />

<br />

sage: A.charpoly(’x’)<br />

x^2 - 3*x - 2<br />

sage: A.charpoly(’y’)<br />

y^2 - 3*y - 2<br />

sage: A._cache[’charpoly_linbox’]<br />

x^2 - 3*x - 2<br />

column(i, from_list=False)<br />

Return the i-th column <strong>of</strong> this matrix as a dense vector.<br />

INPUT:<br />

• i - integer<br />

• from_list - ignored<br />

EXAMPLES:<br />

sage: matrix(QQ,2,[1/5,-2/3,3/4,4/9]).column(1)<br />

(-2/3, 4/9)<br />

sage: matrix(QQ,2,[1/5,-2/3,3/4,4/9]).column(1,from_list=True)<br />

(-2/3, 4/9)<br />

sage: matrix(QQ,2,[1/5,-2/3,3/4,4/9]).column(-1)<br />

(-2/3, 4/9)<br />

341

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

Saved successfully!

Ooh no, something went wrong!