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: factor(a.charpoly())<br />

x^2 * (x^2 - 34*x - 80)<br />

sage: b = matrix(QQ, 4, [-1, 2, 2, 0, 0, 4, 2, 2, 0, 0, -1, -2, 0, -4, 0, 4])<br />

sage: a = matrix(QQ, 4, [1, 1, 0,0, 0,1,0,0, 0,0,5,0, 0,0,0,5])<br />

sage: c = b^(-1)*a*b<br />

sage: factor(c.minpoly())<br />

(x - 5) * (x - 1)^2<br />

sage: factor(c.charpoly())<br />

(x - 5)^2 * (x - 1)^2<br />

prod_<strong>of</strong>_row_sums(cols)<br />

r<strong>and</strong>omize(density=1, num_bound=2, den_bound=2, distribution=None, 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 />

If x <strong>and</strong> y are given, r<strong>and</strong>omized entries <strong>of</strong> this matrix have numerators <strong>and</strong> denominators bounded by x<br />

<strong>and</strong> y <strong>and</strong> have density 1.<br />

INPUT:<br />

•density - number between 0 <strong>and</strong> 1 (default: 1)<br />

•num_bound - numerator bound (default: 2)<br />

•den_bound - denominator bound (default: 2)<br />

•distribution - None or ‘1/n’ (default: None); if ‘1/n’ then num_bound,<br />

den_bound are ignored <strong>and</strong> numbers are chosen using the GMP function<br />

mpq_r<strong>and</strong>omize_entry_recip_uniform<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(QQ,2,4); a.r<strong>and</strong>omize(); a<br />

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

[ 1 -1 2 1]<br />

sage: a = matrix(QQ,2,4); a.r<strong>and</strong>omize(density=0.5); a<br />

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

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

sage: a = matrix(QQ,2,4); a.r<strong>and</strong>omize(num_bound=100, den_bound=100); a<br />

[ 14/27 21/25 43/42 -48/67]<br />

[-19/55 64/67 -11/51 76]<br />

sage: a = matrix(QQ,2,4); a.r<strong>and</strong>omize(distribution=’1/n’); a<br />

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

[ 1 1/39 2 -1955/2]<br />

rank()<br />

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

EXAMPLES:: sage: matrix(QQ,3,[1..9]).rank() 2 sage: matrix(QQ,100,[1..100^2]).rank() 2<br />

row(i, from_list=False)<br />

Return the i-th row <strong>of</strong> this matrix as a dense vector.<br />

INPUT:<br />

• i - integer<br />

• from_list - ignored<br />

346 Chapter 18. Dense matrices over the rational field

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

Saved successfully!

Ooh no, something went wrong!