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.

CHAPTER<br />

THREE<br />

MATRICES OVER AN ARBITRARY RING<br />

AUTHORS:<br />

• William Stein<br />

• Martin Albrecht: conversion to Pyrex<br />

• Jaap Spies: various functions<br />

• Gary Zablackis: fixed a sign bug in generic determinant.<br />

• William Stein <strong>and</strong> Robert Bradshaw - complete restructuring.<br />

• Rob Beezer - refactor kernel functions.<br />

Elements <strong>of</strong> matrix spaces are <strong>of</strong> class Matrix (or a class derived from Matrix). They can be either sparse or dense,<br />

<strong>and</strong> can be defined over any base ring.<br />

EXAMPLES:<br />

We create the 2 × 3 matrix<br />

as an element <strong>of</strong> a matrix space over Q:<br />

( 1 2<br />

) 3<br />

4 5 6<br />

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

sage: A = M([1,2,3, 4,5,6]); A<br />

[1 2 3]<br />

[4 5 6]<br />

sage: A.parent()<br />

Full MatrixSpace <strong>of</strong> 2 by 3 dense matrices over Rational Field<br />

Alternatively, we could create A more directly as follows (which would completely avoid having to create the matrix<br />

space):<br />

sage: A = matrix(QQ, 2, [1,2,3, 4,5,6]); A<br />

[1 2 3]<br />

[4 5 6]<br />

We next change the top-right entry <strong>of</strong> A. Note that matrix indexing is 0-based in <strong>Sage</strong>, so the top right entry is (0, 2),<br />

which should be thought <strong>of</strong> as “row number 0, column number 2”.<br />

sage: A[0,2] = 389<br />

sage: A<br />

[ 1 2 389]<br />

[ 4 5 6]<br />

59

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

Saved successfully!

Ooh no, something went wrong!