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

Companion matrices may be selected as any one <strong>of</strong> four different types. See the documentation for the<br />

companion matrix constructor, sage.matrix.constructor.companion_matrix(), for more<br />

information.<br />

sage: A = matrix(QQ, [[35, -18, -2, -45],<br />

... [22, -22, 12, -16],<br />

... [ 5, -12, 12, 4],<br />

... [16, -6, -4, -23]])<br />

sage: A.rational_form(format=’right’)<br />

[ 2| 0 0 0]<br />

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

[ 0| 0 0 10]<br />

[ 0| 1 0 -1]<br />

[ 0| 0 1 0]<br />

sage: A.rational_form(format=’bottom’)<br />

[ 2| 0 0 0]<br />

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

[ 0| 0 1 0]<br />

[ 0| 0 0 1]<br />

[ 0|10 -1 0]<br />

sage: A.rational_form(format=’left’)<br />

[ 2| 0 0 0]<br />

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

[ 0| 0 1 0]<br />

[ 0|-1 0 1]<br />

[ 0|10 0 0]<br />

sage: A.rational_form(format=’top’)<br />

[ 2| 0 0 0]<br />

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

[ 0| 0 -1 10]<br />

[ 0| 1 0 0]<br />

[ 0| 0 1 0]<br />

TESTS:<br />

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

sage: A.rational_form()<br />

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

...<br />

TypeError: matrix must be square, not 2 x 3<br />

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

sage: A.rational_form()<br />

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

...<br />

TypeError: matrix entries must come from an exact field, not Ring <strong>of</strong> integers modulo 6<br />

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

sage: A.rational_form()<br />

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

...<br />

TypeError: matrix entries must come from an exact field, not Real Double Field<br />

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

sage: A.rational_form(format=’junk’)<br />

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

...<br />

ValueError: ’format’ keyword must be ’right’, ’bottom’, ’left’, ’top’ or ’invariants’, not j<br />

229

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

Saved successfully!

Ooh no, something went wrong!