12.07.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices

Sage Reference Manual: Matrices and Spaces of Matrices

Sage Reference Manual: Matrices and Spaces of Matrices

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<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.2Full MatrixSpace <strong>of</strong> 10 by 2147483648 dense matrices over Integer Ring # 64-bitsage: MatrixSpace(ZZ,2^31,10)... # 32-bitValueError: number <strong>of</strong> rows <strong>and</strong> columns must be less than 2^31 (on a 32-bit computer -- use a 64-Full MatrixSpace <strong>of</strong> 2147483648 by 10 dense matrices over Integer Ring # 64-bitsage: MatrixSpace(ZZ,10,10).category()Category <strong>of</strong> algebras over Integer Ringsage: MatrixSpace(QQ,10).category()Category <strong>of</strong> algebras over Rational Fieldbase_extend(R)Return base extension <strong>of</strong> this matrix space to R.INPUT:•R - ringOUTPUT: a matrix spaceEXAMPLES:sage: Mat(ZZ,3,5).base_extend(QQ)Full MatrixSpace <strong>of</strong> 3 by 5 dense matrices over Rational Fieldsage: Mat(QQ,3,5).base_extend(GF(7))Traceback (most recent call last):...TypeError: no base extension definedbasis()Returns a basis for this matrix space.Warning: This will <strong>of</strong> course compute every generator <strong>of</strong> this matrix space. So for large matrices,this could take a long time, waste a massive amount <strong>of</strong> memory (for dense matrices), <strong>and</strong> is likely notvery useful. Don’t use this on large matrix spaces.EXAMPLES:sage: Mat(ZZ,2,2).basis()[[1 0] [0 1] [0 0] [0 0][0 0], [0 0], [1 0], [0 1]]cached_method(f, name=None, key=None)A decorator for cached methods.EXAMPLES:In the following examples, one can see how a cached method works in application. Below, we demonstratewhat is done behind the scenes:sage: class C:....: @cached_method....: def __hash__(self):....: print "compute hash"....: return int(5)....: @cached_method....: def f(self, x):....: print "computing cached method"....: return x*24 Chapter 1. Matrix <strong>Spaces</strong>

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

Saved successfully!

Ooh no, something went wrong!