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

that the matrix entries are in a field (specifically, the field <strong>of</strong> fractions <strong>of</strong> the base ring <strong>of</strong> the matrix).<br />

INPUT:<br />

•algorithm – string. Which algorithm to use. Choices are<br />

–’default’: Let <strong>Sage</strong> choose an algorithm (default).<br />

–’classical’: Gauss elimination.<br />

–’strassen’: use a Strassen divide <strong>and</strong> conquer algorithm (if available)<br />

•cut<strong>of</strong>f – integer. Only used if the Strassen algorithm is selected.<br />

•transformation – boolean. Whether to also return the transformation matrix. Some matrix<br />

backends do not provide this information, in which case this option is ignored.<br />

OUTPUT:<br />

The matrix self is put into echelon form. Nothing is returned unless the keyword option<br />

transformation=True is specified, in which case the transformation matrix is returned.<br />

EXAMPLES:<br />

sage: a = matrix(QQ,3,range(9)); a<br />

[0 1 2]<br />

[3 4 5]<br />

[6 7 8]<br />

sage: a.echelonize()<br />

sage: a<br />

[ 1 0 -1]<br />

[ 0 1 2]<br />

[ 0 0 0]<br />

An immutable matrix cannot be transformed into echelon form. Use self.echelon_form() instead:<br />

sage: a = matrix(QQ,3,range(9)); a.set_immutable()<br />

sage: a.echelonize()<br />

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

...<br />

ValueError: matrix is immutable; please change a copy instead<br />

(i.e., use copy(M) to change a copy <strong>of</strong> M).<br />

sage: a.echelon_form()<br />

[ 1 0 -1]<br />

[ 0 1 2]<br />

[ 0 0 0]<br />

Echelon form over the integers is what is also classically <strong>of</strong>ten known as Hermite normal form:<br />

sage: a = matrix(ZZ,3,range(9))<br />

sage: a.echelonize(); a<br />

[ 3 0 -3]<br />

[ 0 1 2]<br />

[ 0 0 0]<br />

We compute an echelon form both over a domain <strong>and</strong> fraction field:<br />

sage: R. = QQ[]<br />

sage: a = matrix(R, 2, [x,y,x,y])<br />

sage: a.echelon_form()<br />

[x y]<br />

[x y]<br />

# not very useful -- why two copies <strong>of</strong> the same row<br />

154 Chapter 7. Base class for matrices, part 2

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

Saved successfully!

Ooh no, something went wrong!