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

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

...<br />

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

columns(copy=True)<br />

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

INPUT:<br />

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

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

EXAMPLES:<br />

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

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

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

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

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

[(), ()]<br />

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

[]<br />

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

sage: parent(m.columns()[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 columns.<br />

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

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

sage: v.is_sparse()<br />

True<br />

TESTS:<br />

sage: A = matrix(QQ, 4, range(16))<br />

sage: A.columns(’junk’)<br />

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

...<br />

ValueError: ’copy’ must be True or False, not junk<br />

delete_columns(dcols, check=True)<br />

Return the matrix constructed from deleting the columns with indices in the dcols list.<br />

INPUT:<br />

•dcols - list <strong>of</strong> indices <strong>of</strong> columns to be deleted from self.<br />

•check - checks whether any index in dcols is out <strong>of</strong> range. Defaults to True.<br />

SEE ALSO: The methods delete_rows() <strong>and</strong> matrix_from_columns() are related.<br />

EXAMPLES:<br />

sage: A = Matrix(3,4,range(12)); A<br />

[ 0 1 2 3]<br />

[ 4 5 6 7]<br />

[ 8 9 10 11]<br />

sage: A.delete_columns([0,2])<br />

[ 1 3]<br />

101

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

Saved successfully!

Ooh no, something went wrong!