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.

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

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

sage: S. = R.quo((b^3))<br />

sage: A = matrix(S, [[x*y^2,2*x],[2,x^10*y]])<br />

sage: A<br />

[ x*y^2 2*x]<br />

[ 2 x^10*y]<br />

sage: A.charpoly(’T’)<br />

T^2 + (-x^10*y - x*y^2)*T - 4*x<br />

TESTS:<br />

sage: P. = PolynomialRing(Rationals())<br />

sage: u = MatrixSpace(P,3)([[0,0,a],[1,0,b],[0,1,c]])<br />

sage: Q. = PolynomialRing(P)<br />

sage: u.charpoly(’x’)<br />

x^3 - c*x^2 - b*x - a<br />

A test case from trac ticket #6442. Prior to trac ticket #12292, the call to A.det() would attempt to use<br />

the cached charpoly, <strong>and</strong> crash if an empty dictionary was cached. We don’t cache dictionaries anymore,<br />

but this test should still pass:<br />

sage: z = Zp(p=5)<br />

sage: A = matrix(z, [ [3 + O(5^1), 4 + O(5^1), 4 + O(5^1)],<br />

... [2*5^2 + O(5^3), 2 + O(5^1), 1 + O(5^1)],<br />

... [5 + O(5^2), 1 + O(5^1), 1 + O(5^1)] ])<br />

sage: A.charpoly(algorithm=’hessenberg’)<br />

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

...<br />

ValueError: negative valuation<br />

sage: A.det()<br />

3 + O(5)<br />

The cached polynomial should be independent <strong>of</strong> the var argument (trac ticket #12292). We check (indirectly)<br />

that the second call uses the cached value by noting that its result is not cached:<br />

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

sage: A = M(range(0, 2^2))<br />

sage: type(A)<br />

<br />

sage: A.charpoly(’x’)<br />

x^2 - 3.00000000000000*x - 2.00000000000000<br />

sage: A.charpoly(’y’)<br />

y^2 - 3.00000000000000*y - 2.00000000000000<br />

sage: A._cache[’charpoly’]<br />

x^2 - 3.00000000000000*x - 2.00000000000000<br />

AUTHORS:<br />

•Unknown: No author specified in the file from 2009-06-25<br />

•Sebastian Pancratz (2009-06-25): Include the division-free algorithm<br />

cholesky()<br />

Returns the Cholesky decomposition <strong>of</strong> a symmetric or Hermitian matrix.<br />

INPUT:<br />

A square matrix that is real, symmetric <strong>and</strong> positive definite. Or a square matrix that is complex, Hermitian<br />

<strong>and</strong> positive definite. Generally, the base ring for the entries <strong>of</strong> the matrix needs to be a subfield <strong>of</strong> the<br />

algebraic numbers (QQbar). Examples include the rational numbers (QQ), some number fields, <strong>and</strong> real<br />

algebraic numbers <strong>and</strong> the algebraic numbers themselves.<br />

134 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!