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

Check that the determinant is computed from a cached charpoly properly:<br />

sage: A = matrix(RR, [ [1, 0, 1/2],<br />

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

... [0, 0, -2 ] ])<br />

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

sage: _ = A.charpoly()<br />

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

True<br />

AUTHORS:<br />

•Unknown: No author specified in the file from 2009-06-25<br />

•Sebastian Pancratz (2009-06-25): Use the division-free algorithm for charpoly<br />

•Thierry Monteil (2010-10-05): Bugfix for trac ticket #10063, so that the determinant is computed<br />

even for rings for which the is_field method is not implemented.<br />

diagonal()<br />

Return the diagonal entries <strong>of</strong> self.<br />

OUTPUT:<br />

A list containing the entries <strong>of</strong> the matrix that have equal row <strong>and</strong> column indices, in order <strong>of</strong> the indices.<br />

Behavior is not limited to square matrices.<br />

EXAMPLES:<br />

sage: A = matrix([[2,5],[3,7]]); A<br />

[2 5]<br />

[3 7]<br />

sage: A.diagonal()<br />

[2, 7]<br />

Two rectangular matrices.<br />

sage: B = matrix(3, 7, range(21)); B<br />

[ 0 1 2 3 4 5 6]<br />

[ 7 8 9 10 11 12 13]<br />

[14 15 16 17 18 19 20]<br />

sage: B.diagonal()<br />

[0, 8, 16]<br />

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

[0 1]<br />

[2 3]<br />

[4 5]<br />

sage: C.diagonal()<br />

[0, 3]<br />

Empty matrices behave properly.<br />

sage: E = matrix(0, 5, []); E<br />

[]<br />

sage: E.diagonal()<br />

[]<br />

echelon_form(algorithm=’default’, cut<strong>of</strong>f=0, **kwds)<br />

Return the echelon form <strong>of</strong> self.<br />

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