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

sage: q = t^5 + t - 17<br />

sage: A = block_diagonal_matrix( companion_matrix(p),<br />

... companion_matrix(p^2),<br />

... companion_matrix(q),<br />

... companion_matrix(q) )<br />

sage: A.charpoly(var=t).factor()<br />

(t^3 + 3*t - 8)^3 * (t^5 + t - 17)^2<br />

sage: A.minpoly(var=t).factor()<br />

(t^3 + 3*t - 8)^2 * (t^5 + t - 17)<br />

TESTS:<br />

sage: companion_matrix([4, 5, 1], format=’junk’)<br />

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

...<br />

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

sage: companion_matrix(sin(x))<br />

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

...<br />

TypeError: input must be a polynomial (not a symbolic expression, see docstring), or other itera<br />

sage: companion_matrix([2, 3, 896])<br />

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

...<br />

ValueError: polynomial (or the polynomial implied by coefficients) must be monic, not a leading<br />

sage: F. = GF(2^2)<br />

sage: companion_matrix([4/3, a+1, 1])<br />

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

...<br />

TypeError: unable to find common ring for coefficients from polynomial<br />

sage: A = companion_matrix([1])<br />

sage: A.nrows(); A.ncols()<br />

0<br />

0<br />

sage: A = companion_matrix([])<br />

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

...<br />

ValueError: polynomial cannot be specified by an empty list<br />

AUTHOR:<br />

•Rob Beezer (2011-05-19)<br />

sage.matrix.constructor.diagonal_matrix(arg0=None, arg1=None, arg2=None,<br />

sparse=True)<br />

This function is available as diagonal_matrix(...) <strong>and</strong> matrix.diagonal(...).<br />

Return a square matrix with specified diagonal entries, <strong>and</strong> zeros elsewhere.<br />

FORMATS:<br />

1.diagonal_matrix(entries)<br />

2.diagonal_matrix(nrows, entries)<br />

3.diagonal_matrix(ring, entries)<br />

4.diagonal_matrix(ring, nrows, entries)<br />

28 Chapter 2. Matrix Constructor

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

Saved successfully!

Ooh no, something went wrong!