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.

CHAPTER<br />

FIFTEEN<br />

SPARSE MATRICES OVER Z/NZ FOR<br />

N SMALL<br />

Sparse matrices over Z/nZ for n small<br />

This is a compiled implementation <strong>of</strong> sparse matrices over Z/nZ for n small.<br />

TODO: - move vectors into a Cython vector class - add _add_ <strong>and</strong> _mul_ methods.<br />

EXAMPLES:<br />

sage: a = matrix(Integers(37),3,3,range(9),sparse=True); a<br />

[0 1 2]<br />

[3 4 5]<br />

[6 7 8]<br />

sage: type(a)<br />

<br />

sage: parent(a)<br />

Full MatrixSpace <strong>of</strong> 3 by 3 sparse matrices over Ring <strong>of</strong> integers modulo 37<br />

sage: a^2<br />

[15 18 21]<br />

[ 5 17 29]<br />

[32 16 0]<br />

sage: a+a<br />

[ 0 2 4]<br />

[ 6 8 10]<br />

[12 14 16]<br />

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

[0 1 2]<br />

[3 4 5]<br />

sage: a*b<br />

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

...<br />

TypeError: unsupported oper<strong>and</strong> parent(s) for ’*’: ’Full MatrixSpace <strong>of</strong> 3 by 3 sparse matrices over Ri<br />

sage: b*a<br />

[15 18 21]<br />

[ 5 17 29]<br />

sage: TestSuite(a).run()<br />

sage: TestSuite(b).run()<br />

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

[ 1 0 36]<br />

[ 0 1 2]<br />

[ 0 0 0]<br />

299

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

Saved successfully!

Ooh no, something went wrong!