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

is_sparse()<br />

Returns True if matrices in self are sparse <strong>and</strong> False otherwise.<br />

EXAMPLES:<br />

sage: Mat(GF(2011),10000).is_sparse()<br />

False<br />

sage: Mat(GF(2011),10000,sparse=True).is_sparse()<br />

True<br />

matrix(x=0, coerce=True, copy=True, rows=None)<br />

Create a matrix in self.<br />

INPUT:<br />

•x – (default: 0) data to construct a new matrix from. Can be one <strong>of</strong> the following:<br />

–0, corresponding to the zero matrix;<br />

–1, corresponding to the identity_matrix;<br />

–a matrix, whose dimensions must match self <strong>and</strong> whose base ring must be convertible to the<br />

base ring <strong>of</strong> self;<br />

–a list <strong>of</strong> entries corresponding to all elements <strong>of</strong> the new matrix;<br />

–a list <strong>of</strong> rows with each row given as an iterable;<br />

•coerce – (default: True) whether to coerce x into self;<br />

•copy – (default: True) whether to copy x during construction (makes a difference only if x is a<br />

matrix in self).<br />

OUTPUT:<br />

•a matrix in self.<br />

EXAMPLES:<br />

sage: M = MatrixSpace(ZZ, 2)<br />

sage: M.matrix([[1,0],[0,-1]])<br />

[ 1 0]<br />

[ 0 -1]<br />

sage: M.matrix([1,0,0,-1])<br />

[ 1 0]<br />

[ 0 -1]<br />

sage: M.matrix([1,2,3,4])<br />

[1 2]<br />

[3 4]<br />

sage: M.matrix([1,2,3,4],rows=False)<br />

doctest:...: DeprecationWarning:<br />

’rows=True/False’ parameter is deprecated!<br />

See http://trac.sagemath.org/13012 for details.<br />

[1 3]<br />

[2 4]<br />

Note that the last “flip” cannot be performed if x is a matrix, no matter what is rows (it used to be possible<br />

but was fixed by Trac 10793):<br />

sage: projection = matrix(ZZ,[[1,0,0],[0,1,0]])<br />

sage: projection<br />

[1 0 0]<br />

[0 1 0]<br />

sage: projection.parent()<br />

8 Chapter 1. Matrix <strong>Spaces</strong>

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

Saved successfully!

Ooh no, something went wrong!