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

sage: R.=GF(3)[]<br />

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

sage: A.minpoly()<br />

x^2 + x<br />

Minpoly with pro<strong>of</strong>=False is dramatically (“millions” <strong>of</strong> times!) faster than minpoly with pro<strong>of</strong>=True.<br />

This matters since pro<strong>of</strong>=True is the default, unless you first type ‘’pro<strong>of</strong>.linear_algebra(False)’‘.:<br />

sage: A.minpoly(pro<strong>of</strong>=False) in [x, x+1, x^2+x]<br />

True<br />

r<strong>and</strong>omize(density=1, nonzero=False)<br />

R<strong>and</strong>omize density proportion <strong>of</strong> the entries <strong>of</strong> this matrix, leaving the rest unchanged.<br />

INPUT:<br />

•density - Integer; proportion (roughly) to be considered for changes<br />

•nonzero - Bool (default: False); whether the new entries are forced to be non-zero<br />

OUTPUT:<br />

•None, the matrix is modified in-space<br />

EXAMPLES:<br />

sage: A = matrix(GF(5), 5, 5, 0)<br />

sage: A.r<strong>and</strong>omize(0.5); A<br />

[0 0 0 2 0]<br />

[0 3 0 0 2]<br />

[4 0 0 0 0]<br />

[4 0 0 0 0]<br />

[0 1 0 0 0]<br />

sage: A.r<strong>and</strong>omize(); A<br />

[3 3 2 1 2]<br />

[4 3 3 2 2]<br />

[0 3 3 3 3]<br />

[3 3 2 2 4]<br />

[2 2 2 1 4]<br />

rank()<br />

Return the rank <strong>of</strong> this matrix.<br />

EXAMPLES:<br />

sage: m = matrix(GF(7),5,range(25))<br />

sage: m.rank()<br />

2<br />

Rank is not implemented over the integers modulo a composite yet.:<br />

sage: m = matrix(Integers(4), 2, [2,2,2,2])<br />

sage: m.rank()<br />

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

...<br />

NotImplementedError: Echelon form not implemented over ’Ring <strong>of</strong> integers modulo 4’.<br />

sage.matrix.matrix_modn_dense.is_Matrix_modn_dense(self )<br />

297

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

Saved successfully!

Ooh no, something went wrong!