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: B = matrix(CDF, [[ 2, 4 - 2*I, 2 + 2*I],<br />

... [4 + 2*I, 8, 10*I],<br />

... [2 - 2*I, -10*I, -3]])<br />

sage: B.is_hermitian()<br />

True<br />

sage: [ev.real() for ev in B.eigenvalues()]<br />

[15.88..., 0.08..., -8.97...]<br />

sage: B.cholesky()<br />

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

...<br />

ValueError: matrix is not positive definite<br />

TESTS:<br />

A trivial case.<br />

sage: A = matrix(RDF, 0, [])<br />

sage: A.cholesky()<br />

[]<br />

The Cholesky factorization is only defined for square matrices.<br />

sage: A = matrix(RDF, 4, 5, range(20))<br />

sage: A.cholesky()<br />

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

...<br />

ValueError: Cholesky decomposition requires a square matrix, not a 4 x 5 matrix<br />

condition(p=’frob’)<br />

Returns the condition number <strong>of</strong> a square nonsingular matrix.<br />

Roughly speaking, this is a measure <strong>of</strong> how sensitive the matrix is to round-<strong>of</strong>f errors in numerical computations.<br />

The minimum possible value is 1.0, <strong>and</strong> larger numbers indicate greater sensitivity.<br />

INPUT:<br />

•p - default: ‘frob’ - controls which norm is used to compute the condition number, allowable values<br />

are ‘frob’ (for the Frobenius norm), integers -2, -1, 1, 2, positive <strong>and</strong> negative infinity. See output<br />

discussion for specifics.<br />

OUTPUT:<br />

The condition number <strong>of</strong> a matrix is the product <strong>of</strong> a norm <strong>of</strong> the matrix times the norm <strong>of</strong> the inverse <strong>of</strong><br />

the matrix. This requires that the matrix be square <strong>and</strong> invertible (nonsingular, full rank).<br />

Returned value is a double precision floating point value in RDF, or Infinity. Row <strong>and</strong> column sums<br />

described below are sums <strong>of</strong> the absolute values <strong>of</strong> the entries, where the absolute value <strong>of</strong> the complex<br />

number a + bi is √ a 2 + b 2 . Singular values are the “diagonal” entries <strong>of</strong> the “S” matrix in the singular<br />

value decomposition.<br />

•p = ’frob’: the default norm employed in computing the condition number, the Frobenius norm,<br />

which for a matrix A = (a ij ) computes<br />

⎛<br />

⎝ ∑ i,j<br />

⎞1/2<br />

|a i,j | 2 ⎠<br />

•p = ’sv’: the quotient <strong>of</strong> the maximal <strong>and</strong> minimal singular value.<br />

•p = Infinity or p = oo: the maximum row sum.<br />

358 Chapter 19. Dense matrices using a NumPy backend.

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

Saved successfully!

Ooh no, something went wrong!