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

•i - integer<br />

•from_list - bool (default: False); if true, returns the i‘th element <strong>of</strong> self.rows() (see<br />

rows()), which may be faster, but requires building a list <strong>of</strong> all rows the first time it is called after<br />

an entry <strong>of</strong> the matrix is changed.<br />

EXAMPLES:<br />

sage: a = matrix(2,3,range(6)); a<br />

[0 1 2]<br />

[3 4 5]<br />

sage: a.row(0)<br />

(0, 1, 2)<br />

sage: a.row(1)<br />

(3, 4, 5)<br />

sage: a.row(-1) # last row<br />

(3, 4, 5)<br />

TESTS:<br />

sage: a = matrix(2,3,range(6)); a<br />

[0 1 2]<br />

[3 4 5]<br />

sage: a.row(2)<br />

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

...<br />

IndexError: row index out <strong>of</strong> range<br />

sage: a.row(-3)<br />

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

...<br />

IndexError: row index out <strong>of</strong> range<br />

rows(copy=True)<br />

Return a list <strong>of</strong> the rows <strong>of</strong> self.<br />

INPUT:<br />

•copy - (default: True) if True, return a copy <strong>of</strong> the list <strong>of</strong> rows which is safe to change.<br />

If self is a sparse matrix, rows are returned as sparse vectors, otherwise returned vectors are dense.<br />

EXAMPLES:<br />

sage: matrix(3, [1..9]).rows()<br />

[(1, 2, 3), (4, 5, 6), (7, 8, 9)]<br />

sage: matrix(RR, 2, [sqrt(2), pi, exp(1), 0]).rows()<br />

[(1.41421356237310, 3.14159265358979), (2.71828182845905, 0.000000000000000)]<br />

sage: matrix(RR, 0, 2, []).rows()<br />

[]<br />

sage: matrix(RR, 2, 0, []).rows()<br />

[(), ()]<br />

sage: m = matrix(RR, 3, 3, {(1,2): pi, (2, 2): -1, (0,1): sqrt(2)})<br />

sage: parent(m.rows()[0])<br />

Sparse vector space <strong>of</strong> dimension 3 over Real Field with 53 bits <strong>of</strong> precision<br />

Sparse matrices produce sparse rows.<br />

sage: A = matrix(QQ, 2, range(4), sparse=True)<br />

sage: v = A.rows()[0]<br />

sage: v.is_sparse()<br />

True<br />

109

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

Saved successfully!

Ooh no, something went wrong!