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

Full MatrixSpace <strong>of</strong> 10 by 2147483648 dense matrices over Integer Ring # 64-bit<br />

sage: MatrixSpace(ZZ,2^31,10)<br />

... # 32-bit<br />

ValueError: number <strong>of</strong> rows <strong>and</strong> columns must be less than 2^31 (on a 32-bit computer -- use a 64-<br />

Full MatrixSpace <strong>of</strong> 2147483648 by 10 dense matrices over Integer Ring # 64-bit<br />

sage: MatrixSpace(ZZ,10,10).category()<br />

Category <strong>of</strong> algebras over Integer Ring<br />

sage: MatrixSpace(QQ,10).category()<br />

Category <strong>of</strong> algebras over Rational Field<br />

base_extend(R)<br />

Return base extension <strong>of</strong> this matrix space to R.<br />

INPUT:<br />

•R - ring<br />

OUTPUT: a matrix space<br />

EXAMPLES:<br />

sage: Mat(ZZ,3,5).base_extend(QQ)<br />

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

sage: Mat(QQ,3,5).base_extend(GF(7))<br />

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

...<br />

TypeError: no base extension defined<br />

basis()<br />

Returns a basis for this matrix space.<br />

Warning: This will <strong>of</strong> course compute every generator <strong>of</strong> this matrix space. So for large matrices,<br />

this could take a long time, waste a massive amount <strong>of</strong> memory (for dense matrices), <strong>and</strong> is likely not<br />

very useful. Don’t use this on large matrix spaces.<br />

EXAMPLES:<br />

sage: Mat(ZZ,2,2).basis()<br />

[<br />

[1 0] [0 1] [0 0] [0 0]<br />

[0 0], [0 0], [1 0], [0 1]<br />

]<br />

cached_method(f, name=None)<br />

EXAMPLES:<br />

In the following examples, one can see how a cached method works in applicationy. Below, we demonstrate<br />

what is done behind the scenes:<br />

sage: class C:<br />

....: @cached_method<br />

....: def __hash__(self):<br />

....: print "compute hash"<br />

....: return int(5)<br />

....: @cached_method<br />

....: def f(self, x):<br />

....: print "computing cached method"<br />

....: return x*2<br />

sage: c = C()<br />

sage: type(C.__hash__)<br />

4 Chapter 1. Matrix <strong>Spaces</strong>

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

Saved successfully!

Ooh no, something went wrong!