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

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

Return the product <strong>of</strong> the sums <strong>of</strong> the entries in the submatrix <strong>of</strong> self with given columns.<br />

INPUT:<br />

•cols - a list (or set) <strong>of</strong> integers representing columns <strong>of</strong> self.<br />

OUTPUT: an integer<br />

EXAMPLES:<br />

sage: a = matrix(ZZ,2,3,[1..6]); a<br />

[1 2 3]<br />

[4 5 6]<br />

sage: a.prod_<strong>of</strong>_row_sums([0,2])<br />

40<br />

sage: (1+3)*(4+6)<br />

40<br />

sage: a.prod_<strong>of</strong>_row_sums(set([0,2]))<br />

40<br />

r<strong>and</strong>omize(density=1, x=None, y=None, 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 />

The parameters are the same as the ones for the integer ring’s r<strong>and</strong>om_element function.<br />

If x <strong>and</strong> y are given, r<strong>and</strong>omized entries <strong>of</strong> this matrix have to be between x <strong>and</strong> y <strong>and</strong> have density 1.<br />

INPUT:<br />

•self - a mutable matrix over ZZ<br />

•density - a float between 0 <strong>and</strong> 1<br />

•x, y - if not None, these are passed to the ZZ.r<strong>and</strong>om_element function as the upper <strong>and</strong> lower<br />

endpoints in the uniform distribution<br />

•distribution - would also be passed into ZZ.r<strong>and</strong>om_element if given<br />

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

OUTPUT:<br />

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

EXAMPLES:<br />

sage: A = matrix(ZZ, 2,3, [1..6]); A<br />

[1 2 3]<br />

[4 5 6]<br />

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

sage: A<br />

[-8 2 0]<br />

[ 0 1 -1]<br />

sage: A.r<strong>and</strong>omize(x=-30,y=30)<br />

sage: A<br />

[ 5 -19 24]<br />

[ 24 23 -9]<br />

rank()<br />

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

OUTPUT:<br />

•nonnegative integer - the rank<br />

331

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

Saved successfully!

Ooh no, something went wrong!