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

EXAMPLES: We rescale the second row <strong>of</strong> a matrix over the integers:<br />

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

[0 1]<br />

[2 3]<br />

[4 5]<br />

sage: b = a.with_rescaled_row(1,-2); b<br />

[ 0 1]<br />

[-4 -6]<br />

[ 4 5]<br />

The original matrix is unchanged:<br />

sage: a<br />

[0 1]<br />

[2 3]<br />

[4 5]<br />

Adding a rational multiple is okay, <strong>and</strong> reassigning a variable is okay:<br />

sage: a = a.with_rescaled_row(2,1/3); a<br />

[ 0 1]<br />

[ 2 3]<br />

[4/3 5/3]<br />

with_row_set_to_multiple_<strong>of</strong>_row(i, j, s)<br />

Set row i equal to s times row j, returning a new matrix.<br />

EXAMPLES: We change the second row to -3 times the first row:<br />

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

[0 1 2]<br />

[3 4 5]<br />

sage: b = a.with_row_set_to_multiple_<strong>of</strong>_row(1,0,-3); b<br />

[ 0 1 2]<br />

[ 0 -3 -6]<br />

Note that the original matrix is unchanged:<br />

sage: a<br />

[0 1 2]<br />

[3 4 5]<br />

Adding a rational multiple is okay, <strong>and</strong> reassigning a variable is okay:<br />

sage: a = a.with_row_set_to_multiple_<strong>of</strong>_row(1,0,1/2); a<br />

[ 0 1 2]<br />

[ 0 1/2 1]<br />

with_swapped_columns(c1, c2)<br />

Swap columns c1 <strong>and</strong> c2 <strong>of</strong> self <strong>and</strong> return a new matrix.<br />

INPUT:<br />

•c1, c2 - integers specifying columns <strong>of</strong> self to interchange<br />

OUTPUT:<br />

A new matrix, identical to self except that columns c1 <strong>and</strong> c2 are swapped.<br />

EXAMPLES:<br />

Remember that columns are numbered starting from zero.<br />

93

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

Saved successfully!

Ooh no, something went wrong!