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

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_added_multiple_<strong>of</strong>_row(0,1,1/3); a<br />

[ 1 7/3 11/3]<br />

[ 3 4 5]<br />

with_col_set_to_multiple_<strong>of</strong>_col(i, j, s)<br />

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

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

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

[0 1 2]<br />

[3 4 5]<br />

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

[ 0 0 2]<br />

[ 3 -9 5]<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_col_set_to_multiple_<strong>of</strong>_col(1,0,1/2); a<br />

[ 0 0 2]<br />

[ 3 3/2 5]<br />

with_rescaled_col(i, s, start_row=0)<br />

Replaces i-th col <strong>of</strong> self by s times i-th col <strong>of</strong> self, returning new matrix.<br />

EXAMPLES: We rescale the last column <strong>of</strong> a matrix over the integers:<br />

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

[0 1 2]<br />

[3 4 5]<br />

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

[ 0 1 -4]<br />

[ 3 4 -10]<br />

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_rescaled_col(1,1/3); a<br />

[ 0 1/3 2]<br />

[ 3 4/3 5]<br />

with_rescaled_row(i, s, start_col=0)<br />

Replaces i-th row <strong>of</strong> self by s times i-th row <strong>of</strong> self, returning new matrix.<br />

92 Chapter 5. Base class for matrices, part 0

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

Saved successfully!

Ooh no, something went wrong!