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

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

...<br />

TypeError: Cannot set column with Rational Field elements over Integer Ring, use change_ring<br />

set_row(row, v)<br />

Sets the entries <strong>of</strong> row row to the entries <strong>of</strong> v.<br />

INPUT:<br />

•row - index <strong>of</strong> row to be set.<br />

•v - a list or vector <strong>of</strong> the new entries.<br />

OUTPUT:<br />

Changes the matrix in-place, so there is no output.<br />

EXAMPLES:<br />

New entries may be contained in a vector.:<br />

sage: A = matrix(QQ, 5, range(25))<br />

sage: u = vector(QQ, [0, -1, -2, -3, -4])<br />

sage: A.set_row(2, u)<br />

sage: A<br />

[ 0 1 2 3 4]<br />

[ 5 6 7 8 9]<br />

[ 0 -1 -2 -3 -4]<br />

[15 16 17 18 19]<br />

[20 21 22 23 24]<br />

New entries may be in any sort <strong>of</strong> list.:<br />

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

[1 2]<br />

[3 4]<br />

sage: A.set_row(0, [0, 0]); A<br />

[0 0]<br />

[3 4]<br />

sage: A.set_row(1, (0, 0)); A<br />

[0 0]<br />

[0 0]<br />

TESTS:<br />

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

sage: A.set_row(2, [0, 0]); A<br />

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

...<br />

ValueError: row number must be between 0 <strong>and</strong> 1 (inclusive), not 2<br />

sage: A.set_row(0, [0, 0, 0])<br />

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

...<br />

ValueError: list <strong>of</strong> new entries must be <strong>of</strong> length 2 (not 3)<br />

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

sage: A.set_row(0, [1/3, 1]); A<br />

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

...<br />

TypeError: Cannot set row with Rational Field elements over Integer Ring, use change_ring fi<br />

111

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

Saved successfully!

Ooh no, something went wrong!