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

Full MatrixSpace <strong>of</strong> 2 by 2 dense matrices over Finite Field in a <strong>of</strong> size 5^2<br />

sage: A.change_ring(ZZ)<br />

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

...<br />

TypeError: matrix has denominators so can’t change to ZZ.<br />

Changing rings preserves subdivisions:<br />

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

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

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

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

sage: A.change_ring(GF(25,’a’))<br />

[3 2]<br />

[---]<br />

[2 4]<br />

commutator(other)<br />

Return the commutator self*other - other*self.<br />

EXAMPLES:<br />

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

sage: B = Matrix(ZZ, 2, 2, [0, 1, 0, 0])<br />

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

[-2 -3]<br />

[ 0 2]<br />

sage: A.commutator(B) == -B.commutator(A)<br />

True<br />

dict()<br />

Dictionary <strong>of</strong> the elements <strong>of</strong> self with keys pairs (i,j) <strong>and</strong> values the nonzero entries <strong>of</strong> self.<br />

It is safe to change the returned dictionary.<br />

EXAMPLES:<br />

sage: R. = QQ[]<br />

sage: a = matrix(R,2,[x,y,0, 0,0,2*x+y]); a<br />

[ x y 0]<br />

[ 0 0 2*x + y]<br />

sage: d = a.dict(); d<br />

{(0, 1): y, (1, 2): 2*x + y, (0, 0): x}<br />

Notice that changing the returned list does not change a (the list is a copy):<br />

sage: d[0,0] = 25<br />

sage: a<br />

[ x y 0]<br />

[ 0 0 2*x + y]<br />

dimensions()<br />

Returns the dimensions <strong>of</strong> this matrix as the tuple (nrows, ncols).<br />

EXAMPLES:<br />

sage: M = matrix([[1,2,3],[4,5,6]])<br />

sage: N = M.transpose()<br />

sage: M.dimensions()<br />

(2, 3)<br />

72 Chapter 5. Base class for matrices, part 0

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

Saved successfully!

Ooh no, something went wrong!