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

The subdivide option will add a natural subdivision between self <strong>and</strong> right.<br />

For more details about how subdivisions are managed when augmenting, see<br />

sage.matrix.matrix1.Matrix.augment().<br />

sage: A = matrix(QQ, 3, 5, range(15), sparse=True)<br />

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

sage: A.augment(B, subdivide=True)<br />

[ 0 1 2 3 4| 0 1 2]<br />

[ 5 6 7 8 9| 3 4 5]<br />

[10 11 12 13 14| 6 7 8]<br />

TESTS:<br />

Verify that Trac #12689 is fixed:<br />

sage: A = identity_matrix(QQ, 2, sparse=True)<br />

sage: B = identity_matrix(ZZ, 2, sparse=True)<br />

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

[1 0 1 0]<br />

[0 1 0 1]<br />

change_ring(ring)<br />

Return the matrix obtained by coercing the entries <strong>of</strong> this matrix into the given ring.<br />

Always returns a copy (unless self is immutable, in which case returns self).<br />

EXAMPLES:<br />

sage: A = matrix(QQ[’x,y’], 2, [0,-1,2*x,-2], sparse=True); A<br />

[ 0 -1]<br />

[2*x -2]<br />

sage: A.change_ring(QQ[’x,y,z’])<br />

[ 0 -1]<br />

[2*x -2]<br />

Subdivisions are preserved when changing rings:<br />

sage: A.subdivide([2],[]); A<br />

[ 0 -1]<br />

[2*x -2]<br />

[-------]<br />

sage: A.change_ring(RR[’x,y’])<br />

[ 0 -1.00000000000000]<br />

[2.00000000000000*x -2.00000000000000]<br />

[-------------------------------------]<br />

charpoly(var=’x’, **kwds)<br />

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

Note - the generic sparse charpoly implementation in <strong>Sage</strong> is to just compute the charpoly <strong>of</strong> the corresponding<br />

dense matrix, so this could use a lot <strong>of</strong> memory. In particular, for this matrix, the charpoly will<br />

be computed using a dense algorithm.<br />

EXAMPLES:<br />

sage: A = matrix(ZZ, 4, range(16), sparse=True)<br />

sage: A.charpoly()<br />

x^4 - 30*x^3 - 80*x^2<br />

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

y^4 - 30*y^3 - 80*y^2<br />

sage: A.charpoly()<br />

x^4 - 30*x^3 - 80*x^2<br />

284 Chapter 11. Base class for sparse matrices

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

Saved successfully!

Ooh no, something went wrong!