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

[ 1 1 0 2 2]<br />

[ 1 0 1 1 4]<br />

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

Set the 2 x 3 submatrix <strong>of</strong> M starting at row index <strong>and</strong> column index 1:<br />

sage: M[1:3,[1..3]] = M[2:4,0:3]; M<br />

[ 1 -2 -1 -1 9]<br />

[ 1 1 0 1 2]<br />

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

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

Set part <strong>of</strong> the first column <strong>of</strong> M:<br />

sage: M[1:,0]=[[2],[3],[4]]; M<br />

[ 1 -2 -1 -1 9]<br />

[ 2 1 0 1 2]<br />

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

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

Or do a similar thing with a vector:<br />

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

[ 1 -2 -1 -1 9]<br />

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

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

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

Or a constant:<br />

sage: M[1:,0]=30; M<br />

[ 1 -2 -1 -1 9]<br />

[30 1 0 1 2]<br />

[30 -1 2 -2 4]<br />

[30 2 -2 -1 4]<br />

Set the first row <strong>of</strong> M:<br />

sage: M[0,:]=[[20,21,22,23,24]]; M<br />

[20 21 22 23 24]<br />

[30 1 0 1 2]<br />

[30 -1 2 -2 4]<br />

[30 2 -2 -1 4]<br />

sage: M[0,:]=vector([0,1,2,3,4]); M<br />

[ 0 1 2 3 4]<br />

[30 1 0 1 2]<br />

[30 -1 2 -2 4]<br />

[30 2 -2 -1 4]<br />

sage: M[0,:]=-3; M<br />

[-3 -3 -3 -3 -3]<br />

[30 1 0 1 2]<br />

[30 -1 2 -2 4]<br />

[30 2 -2 -1 4]<br />

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

[ 3 2 -5 0]<br />

[ 1 -1 1 -4]<br />

[ 1 0 1 -3]<br />

62 Chapter 3. <strong>Matrices</strong> over an arbitrary ring

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

Saved successfully!

Ooh no, something went wrong!