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

ValueError: cannot add a multiple <strong>of</strong> a row to itself<br />

If the ring is not specified, <strong>and</strong> a scale parameter is given, the base ring for the matrix is chosen to contain the<br />

scale parameter. Otherwise, if no ring is given, the default is the integers.<br />

sage: E = elementary_matrix(4, row1=1, row2=3)<br />

sage: E.parent()<br />

Full MatrixSpace <strong>of</strong> 4 by 4 dense matrices over Integer Ring<br />

sage: E = elementary_matrix(4, row1=1, scale=4/3)<br />

sage: E.parent()<br />

Full MatrixSpace <strong>of</strong> 4 by 4 dense matrices over Rational Field<br />

sage: E = elementary_matrix(4, row1=1, scale=I)<br />

sage: E.parent()<br />

Full MatrixSpace <strong>of</strong> 4 by 4 dense matrices over Symbolic Ring<br />

sage: E = elementary_matrix(4, row1=1, scale=CDF(I))<br />

sage: E.parent()<br />

Full MatrixSpace <strong>of</strong> 4 by 4 dense matrices over Complex Double Field<br />

sage: E = elementary_matrix(4, row1=1, scale=QQbar(I))<br />

sage: E.parent()<br />

Full MatrixSpace <strong>of</strong> 4 by 4 dense matrices over Algebraic Field<br />

Returned matrices have a dense implementation by default, but a sparse implementation may be requested.<br />

sage: E = elementary_matrix(4, row1=0, row2=1)<br />

sage: E.is_dense()<br />

True<br />

sage: E = elementary_matrix(4, row1=0, row2=1, sparse=True)<br />

sage: E.is_sparse()<br />

True<br />

And the ridiculously small cases. The zero-row matrix cannot be built since then there are no rows to manipulate.<br />

sage: elementary_matrix(QQ, 1, row1=0, row2=0)<br />

[1]<br />

sage: elementary_matrix(QQ, 0, row1=0, row2=0)<br />

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

...<br />

ValueError: size <strong>of</strong> elementary matrix must be 1 or greater, not 0<br />

TESTS:<br />

sage: E = elementary_matrix(’junk’, 5, row1=3, row2=1, scale=12)<br />

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

...<br />

TypeError: optional first parameter must be a ring, not junk<br />

sage: E = elementary_matrix(5, row1=3, scale=’junk’)<br />

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

...<br />

TypeError: scale must be an element <strong>of</strong> some ring, not junk<br />

sage: E = elementary_matrix(ZZ, 5, row1=3, col2=3, scale=12)<br />

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

...<br />

34 Chapter 2. Matrix Constructor

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

Saved successfully!

Ooh no, something went wrong!