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

Performs Gram-Schmidt orthogonalization on the rows <strong>of</strong> the matrix, returning a new matrix <strong>and</strong> a matrix<br />

accomplishing the transformation.<br />

INPUT:<br />

•self - a matrix whose rows are to be orthogonalized.<br />

•orthonormal - default: False - if True the returned orthogonal vectors are unit vectors. This<br />

keyword is ignored if the matrix is over RDF or CDF <strong>and</strong> the results are always orthonormal.<br />

OUTPUT:<br />

A pair <strong>of</strong> matrices, G <strong>and</strong> M such that if A represents self, where the parenthetical properties occur when<br />

orthonormal = True:<br />

•A = M*G<br />

•The rows <strong>of</strong> G are an orthogonal (resp. orthonormal) set <strong>of</strong> vectors.<br />

•G times the conjugate-transpose <strong>of</strong> G is a diagonal (resp. identity) matrix.<br />

•The row space <strong>of</strong> G equals the row space <strong>of</strong> A.<br />

•M is a full-rank matrix with zeros above the diagonal.<br />

For exact rings, any zero vectors produced (when the original vectors are linearly dependent) are not<br />

output, thus the orthonormal set is linearly independent, <strong>and</strong> thus a basis for the row space <strong>of</strong> the original<br />

matrix.<br />

Any notion <strong>of</strong> a Gram-Schmidt procedure requires that the base ring <strong>of</strong> the matrix has a fraction field<br />

implemented. In order to arrive at an orthonormal set, it must be possible to construct square roots <strong>of</strong><br />

the elements <strong>of</strong> the base field. In <strong>Sage</strong>, your best option is the field <strong>of</strong> algebraic numbers, QQbar, which<br />

properly contains the rationals <strong>and</strong> number fields.<br />

If you have an approximate numerical matrix, then this routine requires that your base field be the real<br />

<strong>and</strong> complex double-precision floating point numbers, RDF <strong>and</strong> CDF. In this case, the matrix is treated as<br />

having full rank, as no attempt is made to recognize linear dependence with approximate calculations.<br />

EXAMPLES:<br />

Inexact Rings, Numerical <strong>Matrices</strong>:<br />

First, the inexact rings, CDF <strong>and</strong> RDF.<br />

sage: A = matrix(CDF, [[ 0.6454 + 0.7491*I, -0.8662 + 0.1489*I, 0.7656 - 0.00344*I],<br />

... [-0.2913 + 0.8057*I, 0.8321 + 0.8170*I, -0.6744 + 0.9248*I],<br />

... [ 0.2554 + 0.3517*I, -0.4454 - 0.1715*I, 0.8325 - 0.6282*I]])<br />

sage: G, M = A.gram_schmidt()<br />

sage: G.round(6) # r<strong>and</strong>om signs<br />

[-0.422243 - 0.490087*I 0.566698 - 0.097416*I -0.500882 + 0.002251*I]<br />

[-0.057002 - 0.495035*I -0.35059 - 0.625323*I 0.255514 - 0.415284*I]<br />

[ 0.394105 - 0.421778*I -0.392266 - 0.039345*I -0.352905 + 0.62195*I]<br />

sage: M.round(6) # r<strong>and</strong>om<br />

[ -1.528503 0.0 0.0]<br />

[ 0.459974 - 0.40061*I -1.741233 0.0]<br />

[-0.934304 + 0.148868*I 0.54833 + 0.073202*I -0.550725]<br />

sage: (A - M*G).zero_at(10^-12)<br />

[0.0 0.0 0.0]<br />

[0.0 0.0 0.0]<br />

[0.0 0.0 0.0]<br />

sage: (G*G.conjugate_transpose()).zero_at(10^-12)<br />

[1.0 0.0 0.0]<br />

[0.0 1.0 0.0]<br />

[0.0 0.0 1.0]<br />

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